更新SDK后,Android项目不会构建

时间:2015-06-01 14:36:01

标签: android android-studio gradle

Okey我更新了SDK,之前我的项目正在构建,现在我有很多错误:

/home/user/project/android-project/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/values-v14/values.xml
Error:(17, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
Error:(47, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(17, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
/home/user/Project/android-project/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/values-v11/values.xml
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
Error:(47, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(17, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.

有些人很荒谬:

Error:Attribute "background" has already been defined

我检查了哪个错误点的文件,但我找不到具有该名称的属性。

最后,我看到在:

下生成了两个新文件夹
/ app / build / intermediates / exploded-aar /

appcompact-v7mediarouter-v7

如何禁用他们的一代? 无论如何还有回来吗?

更新

正如Jasper所写,我只需要将targetSdk和compileSdk版本设置为最新版本。但是我仍有一个问题。

它的Error:Attribute "background" has already been defined指向了colors.xml

<resources>
    <color name="black">#000000</color>
    <color name="stats_font_color">#ffa326</color>
    <color name="dark_bg_a70">#b3000000</color>
    <color name="dark_bg_a77">#c4000000</color>
    <color name="gray_a90">#e6313131</color>
    <color name="white">#ffffffff</color>
    <color name="white_a50">#80ffffff</color>
    <color name="white_a35">#59ffffff</color>
    <color name="reminder_table_light">#757575</color>
    <color name="reminder_table_dark">#000000</color>
</resources>

gradle生成错误

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /home/user/Android/Sdk/build-tools/22.0.0/aapt package -f --no-crunch -I /home/user/Android/Sdk/platforms/android-22/android.jar -M /home/user/Project/project/app/build/intermediates/manifests/full/debug/AndroidManifest.xml -S /home/user/Project/project/app/build/intermediates/res/debug -A /home/user/Project/project/app/build/intermediates/assets/debug -m -J /home/user/Project/project/app/build/generated/source/r/debug -F /home/user/Project/project/app/build/intermediates/res/resources-debug.ap_ --debug-mode --custom-package com.projectname -0 apk --output-text-symbols /home/user/Project/project/app/build/intermediates/symbols/debug
  Error Code:
    1
  Output:
/app/build/intermediates/res/debug/values/values.xml:207: error: Attribute "background" has already been defined

我的依赖

dependencies {
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.google.android.gms:play-services:+'
    compile files('libs/android-async-http-sources.jar')
    compile files('libs/android-async-http.jar')
    compile files('libs/commons-lang-2.6-javadoc.jar')
    compile files('libs/commons-lang-2.6-sources.jar')
    compile files('libs/commons-lang-2.6.jar')
    compile files('libs/crashlytics.jar')
    compile files('libs/gesticulate.jar')
    compile files('libs/simple-xml-2.7.jar')
    compile files('libs/urlimageviewhelper-sources.jar')
    compile files('libs/urlimageviewhelper.jar')
}

1 个答案:

答案 0 :(得分:2)

您是否尝试过设置build.gradle?

compileSdkVersion 22
buildToolsVersion "22.0.0"

targetSdkVersion 22

compile&#39; com.android.support:appcompat-v7:22.0。+&#39;