Issue
I used to have an older version of Android Studio (Not entirely sure which one, it was from a few months ago / maybe last year) and everything was working great. It was some kind of RC version, maybe RC-2?
Anyway, last week I updated to the latest version, v1.4, and now gradle and everything else is completely broken. NO CODE HAS CHANGED.
Here's my old gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
This file gives the error "You must use a newer version of the Android Gradle plugin. The minimum supported version is 1.0.0 and the recommended version is 1.3.0".
So, when I change gradle to 1.3.0 (or 1.0.0) that error disappears, but is replaced with 101 errors that all look like this:
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
For example, the above error is referencing an Android file called ldltr-v21/values-ldltr-v21.xml which is not in my project at all. It's a standard Android file with content :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/usr/local/google/buildbot/repo_clients/https___googleplex-android.googlesource.com_a_platform_manifest.git/mnc-supportlib-release/frameworks/support/v7/appcompat/res/values-ldltr-v21/styles_base.xml -->
<eat-comment/>
<style name="Base.Widget.AppCompat.Spinner.Underlined" parent="android:Widget.Material.Spinner.Underlined"/>
</resources>
Again. NONE OF MY CODE HAS CHANGED and suddenly everything is broken. I've also tried cleaning/buildling, invalidating cache and restarting, and reverting to my latest commit / rebuilding. Nothing has worked; how can I fix this?
Solution
Update your build.gradle files.
Use the last stable plugin: 1.3.1
classpath 'com.android.tools.build:gradle:1.3.1'
Update your gradle version, changing the gradle/wrapper/gradle-wrapper.properties
file
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
Then check your dependencies:
AppCompat builds themes that require the APIs with the same level to compile your application.
It means that
//You have to use compileSdkVersion=23
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.0'
//it requires compileSdkVersion 22
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.0.0'
//it requires compileSdkVersion 21
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.0'
Answered By - Gabriele Mariotti
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.