【问题标题】:Build error in android studio在android studio中构建错误
【发布时间】:2016-03-01 14:32:52
【问题描述】:

我的 gradle 文件是这样的

apply plugin: 'com.android.application'

 android {
   compileSdkVersion 19
   buildToolsVersion "19.1.0"

defaultConfig {
    applicationId "com.test.app"
    minSdkVersion 19
    targetSdkVersion 19

    ndk {
        moduleName "opus"
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
    compile 'com.android.support:support-v4:19.1.0'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.code.gson:gson:2.2.4'

}

在构建过程中出现以下错误

<path to project>/app/build/intermediates/res/merged/debug/values-v21/values-v21.xml

Error:(16) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(18) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(24) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(31) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(209) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(211) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
Error:(214) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
Error:(224) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
Error:(231) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
Error:(177) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
Error:(9) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:(6) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:(7) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
Error:(8) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
Error:(10) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
Error:(11) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
Error:(12) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
Error:(13) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
Error:(14) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
Error:(15) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
Error:(17) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
Error:(19) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:(21) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:(23) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
Error:(25) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
Error:(26) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Subtitle'.
Error:(28) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Title'.
Error:(30) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
Error:(32) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
Error:(33) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.
Error:(34) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
Error:(36) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:(38) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse'.
Error:(40) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:(42) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title.Inverse'.
Error:(44) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
Error:(46) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
Error:(48) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:(50) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:(52) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:(53) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.TextView.SpinnerItem'.
Error:(54) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:(56) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:(166) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabText'.
Error:(168) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
Error:(170) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
Error:(172) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.CloseMode'.
Error:(175) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.Overflow'.
Error:(178) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button'.
Error:(179) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless'.
Error:(180) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless.Colored'.
Error:(181) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Small'.
Error:(182) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ButtonBar'.
Error:(183) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.CompoundButton.CheckBox'.
Error:(184) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.CompoundButton.RadioButton'.
Error:(185) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.DropDownItem.Spinner'.
Error:(186) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:(188) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:(190) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabView'.
Error:(192) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.PopupMenu'.
Error:(198) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListPopupWindow'.
Error:(200) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView'.
Error:(201) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView.DropDown'.
Error:(203) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.PopupMenu'.
Error:(213) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.RatingBar'.
Error:(215) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
Error:(220) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
Error:(221) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.TextView.SpinnerItem'.
Error:(222) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Toolbar.Button.Navigation'.
<path to app>/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/res/values-v21/values-v21.xml
Error:(77, 5) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(77, 5) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(126, 5) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(129, 5) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(129, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(129, 5) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(129, 5) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(129, 5) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(129, 5) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(129, 5) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(178, 5) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(211, 5) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:(222, 5) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:(257, 5) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(257, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(257, 5) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(257, 5) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(257, 5) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(257, 5) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(257, 5) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(267, 5) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(267, 5) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(267, 5) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(267, 5) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(267, 5) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(267, 5) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(267, 5) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/Android/Sdk/build-tools/19.1.0/aapt'' finished with non-zero exit value 1

我该如何解决这个问题

【问题讨论】:

  • 似乎是您的资源文件的问题..您是否尝试过清理项目..
  • 是的,还是同样的问题
  • 由于你的targetSdkVersion是19,你可以删除res目录下的values-v21文件夹。然后清理并构建您的项目。
  • 此外,如果您尝试使用 Material 主题,请确保您已遵循本指南:developer.android.com/training/material/theme.html。否则,请考虑为您的项目更改主题。
  • 我删除了文件夹 values-v21 并执行清理和构建项目,但仍然存在问题

标签: android android-studio google-play-services android-support-library


【解决方案1】:

由于您正在使用:

 compile 'com.google.android.gms:play-services:+'

您正在添加具有依赖关系的最新版本

 <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>support-v4</artifactId>
      <version>22.2.0</version>
      <scope>compile</scope>
      <type>aar</type>
    </dependency>
  </dependencies>

您可以查看 gms\play-services-basement\8.3.0 pom 文件。

编译项目需要 API 22 然后更改:

compileSdkVersion 22

另外我建议你使用最新的api 23

   compileSdkVersion 23
   buildToolsVersion "23.0.1"

并且不要在您的依赖项中使用+

【讨论】:

    【解决方案2】:

    你的 logcat 抛出了什么

    Error:(16) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
    

    设置编译sdk version to 21

     compileSdkVersion 21
     buildToolsVersion '23.0.0'
    

    然后调用

    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.google.android.gms:play-services:6.5.87'
    

    然后click Apply -&gt; click OK, clean and build project and run it

    请勿拨打compile 'com.android.support:support-v4:19.1.0'

    阅读Material Theme Setup

    AppCompat v7 r21 returning error in values.xml?

    【讨论】:

    • 我不需要材料设计
    • 你设置compileSdkVersion 21了吗??
    • compile 'com.google.android.gms:play-services:6.5.87'
    • 我只想要 kitkat 的应用程序
    • 更改“com.google.android.gms:play-services:6.5.87”后会产生错误 GcmListenerService not found
    猜你喜欢
    • 1970-01-01
    • 2014-05-08
    • 1970-01-01
    • 1970-01-01
    • 2015-05-10
    • 2018-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多