更新Android Studio后Android会出现问题

时间:2015-10-26 05:23:56

标签: android android-studio gradle android-gradle android-sdk-tools

我曾经有一个旧版本的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错误替换为全部,如下所示:

  

错误:(2)检索项目的父项时出错:找不到资源   匹配给定名称'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>

再次。我的代码没有改变,突然间一切都坏了。我也尝试过清理/构建,使缓存无效并重新启动,并恢复到我最近的提交/重建。没有任何效果;我怎样才能解决这个问题?

1 个答案:

答案 0 :(得分:1)

更新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'