Android 项目构建失败,检索项目 : No resource found that matches the given name 的父项时出错

标签 android android-studio

我最近安装了 Android Studio 1.5.1 版的全新副本。我导入了一个基于以前版本的 Android Studio 构建的项目,并尝试加载到 IDE 中。但它开始给我这个错误。

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\yomal.ds\AppData\Local\Android\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1
C:\Users\yomal.ds\AndroidStudio_Workspace\ClaimAssistant\app\build\intermediates\res\merged\debug\values-v23\values-v23.xml
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(18) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

我检查了我的 gradle.build,据我所知它看起来不错。 这是我的 gradle.build 文件。

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.informaticsint.claimassistant"
    minSdkVersion 14
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/gcm.jar')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.google.android.gms:play-services-identity:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
}

我尝试创建一个新项目并将以前的项目源添加到新项目中。但是当我将 SDK 版本设置为 22 时会弹出此错误。

我遇到过同样的事情,但答案没有用。 Error retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23

我尝试将他们每个版本的支持库版本从 22 - 22.2.1 降级

但是当我将项目设置为在 SDK 23 中编译时,它工作正常但会导致一些其他问题。这就是我这样做时发生的情况。 resource error in android studio after update: No Resource Found

最佳答案

正如我们在评论中发现的那样,问题是依赖性不匹配。

如问题所示,它是针对 22 api 版本进行编译的。 支持库必须与编译 sdk 版本相对应,在本例中也是如此。

但是8.4.0 Play Services实际上依赖于23+的支持库,由于支持库上有22 compileSdk和22+版本,所以找不到资源。

要解决这些问题,有两种解决方案:

  1. 将 Play 服务降级到 7.4.0
  2. 将compileSdk和support-library升级到23版本

调试版本不匹配的最简单方法是运行

 .gradlew dependencies

在你的应用程序模块上(没有项目的根目录),所以终端命令应该是这样的

 cd app-folder/
 ../gradlew dependencies

然后检查依赖关系树,看看是否有什么突出的地方。

关于Android 项目构建失败,检索项目 : No resource found that matches the given name 的父项时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35017030/

相关文章:

java - 如何防止负数/负数

java - Pdf 查看器的小依赖是什么?

java - 在 android 的父级或祖先上下文中找不到方法 onClickcrea(View) :onClick

android - 使用存储访问框架/SD 创建 .nomedia 文件

android - 在 Android 中镜像前置摄像头

Android - actionBar.setDisplayHomeAsUpEnabled 问题

android - 无法解析 style.xml 中的符号 'Theme' (Android Studio)

android-studio - 运行任务时显示Gradle Console

android - 升级build tools版本android studio有什么优缺点

android - 访问 wifi.getScanResults() 中的结果时发生崩溃