Android gradle 更新后出现问题 Android Studio
Android gradle trouble after updating Android Studio
我曾经有一个旧版本的 Android Studio(不完全确定是哪一个,它是几个月前的/可能是去年的)并且一切都运行良好。这是某种 RC 版本,也许是 RC-2?
无论如何,上周我更新到最新版本 v1.4,现在 gradle 其他一切都完全崩溃了。没有代码改变。
这是我的旧 gradle 文件:
// 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()
}
}
此文件给出错误 "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".
因此,当我将 gradle 更改为 1.3.0(或 1.0.0)时,该错误消失了,但被 101 个错误所取代,这些错误看起来都像这样:
Error:(2) Error retrieving parent for item: No resource found that
matches the given name 'android:Widget.Material.Spinner.Underlined'.
例如,上面的错误引用了一个名为 ldltr-v21/values-ldltr-v21.xml 的 Android 文件,它根本不在我的项目中。这是一个标准 Android 文件,内容为:
<?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>
再次。 NONE 我的代码已更改,突然间一切都被破坏了。我也试过 cleaning/buildling,使缓存无效并重新启动,然后恢复到我最近的提交/重建。没有任何效果;我怎样才能解决这个问题?
更新您的 build.gradle 个文件。
使用最后一个稳定的插件:1.3.1
classpath 'com.android.tools.build:gradle:1.3.1'
更新您的 gradle 版本,更改 gradle/wrapper/gradle-wrapper.properties
文件
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
然后检查你的依赖:
AppCompat 构建的主题需要相同级别的 API 来编译您的应用程序。
表示
//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'
我曾经有一个旧版本的 Android Studio(不完全确定是哪一个,它是几个月前的/可能是去年的)并且一切都运行良好。这是某种 RC 版本,也许是 RC-2?
无论如何,上周我更新到最新版本 v1.4,现在 gradle 其他一切都完全崩溃了。没有代码改变。
这是我的旧 gradle 文件:
// 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()
}
}
此文件给出错误 "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".
因此,当我将 gradle 更改为 1.3.0(或 1.0.0)时,该错误消失了,但被 101 个错误所取代,这些错误看起来都像这样:
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
例如,上面的错误引用了一个名为 ldltr-v21/values-ldltr-v21.xml 的 Android 文件,它根本不在我的项目中。这是一个标准 Android 文件,内容为:
<?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>
再次。 NONE 我的代码已更改,突然间一切都被破坏了。我也试过 cleaning/buildling,使缓存无效并重新启动,然后恢复到我最近的提交/重建。没有任何效果;我怎样才能解决这个问题?
更新您的 build.gradle 个文件。
使用最后一个稳定的插件:1.3.1
classpath 'com.android.tools.build:gradle:1.3.1'
更新您的 gradle 版本,更改 gradle/wrapper/gradle-wrapper.properties
文件
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
然后检查你的依赖:
AppCompat 构建的主题需要相同级别的 API 来编译您的应用程序。
表示
//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'