检索项目的父项时出错:找不到与给定名称“android:TextAppearance.Material.Widget.Button.Borderless.Colored”匹配的资源

新手上路,请多包涵

当我在 android studio 中开始新项目时,我收到了这些错误。

错误:(1) 检索项目的父项时出错:找不到与给定名称“android:TextAppearance.Material.Widget.Button.Borderless.Colored”匹配的资源。

错误:(1) 检索项目的父项时出错:找不到与给定名称“android:TextAppearance.Material.Widget.Button.Borderless.Colored”匹配的资源。

错误:任务“:app:processDebugResources”执行失败。 com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.2\aapt .exe” 以非零退出值 1 结束

android项目中的文件包含错误如下:

  <?xml version="1.0" encoding="utf-8"?>
 <resources>
  <style name="Base.TextAppearance.AppCompat.Widget.Button.Borderless.Colored" parent="android:TextAppearance.Material.Widget.Button.Borderless.Colored"/>
  <style name="Base.TextAppearance.AppCompat.Widget.Button.Colored" parent="android:TextAppearance.Material.Widget.Button.Colored"/>
  <style name="TextAppearance.AppCompat.Notification.Info.Media"/>
  <style name="TextAppearance.AppCompat.Notification.Media"/>
  <style name="TextAppearance.AppCompat.Notification.Time.Media"/>
  <style name="TextAppearance.AppCompat.Notification.Title.Media"/>
 </resources>

构建.gradle:

 apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.anmol.checkboxapp"
    minSdkVersion 15
    targetSdkVersion 23
    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 'com.android.support:appcompat-v7:25.1.0'
}

如果有人有这个问题的解决方案,请帮忙

原文由 Anmol Nijhawan 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 434
2 个回答

您编译的 SDK 版本必须与支持库匹配。执行以下操作 之一

1.在你的 Build.gradle 改变

compile 'com.android.support:appcompat-v7:23.0.1'

2.或改变:

 compileSdkVersion 23
buildToolsVersion "23.0.2"

compileSdkVersion 25
buildToolsVersion "25.0.2"

当您使用时compile 'com.android.support:appcompat-v7:25.3.1'

我建议使用第二种方法,因为它使用的是最新的 sdk - 这样您就可以利用最新的 sdk 的新功能。

带有构建工具 27.0.2 的 build.gradle 的 最新示例——

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"
    defaultConfig {
        applicationId "your_applicationID"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:design:27.0.2'
    testCompile 'junit:junit:4.12'
}

如果您在更新版本时遇到问题,例如:

在此处输入图像描述

通过此 答案 使用 Google Maven 存储库 轻松升级

编辑

如果您使用 Facebook 帐户工具包

不要使用: compile 'com.facebook.android:account-kit-sdk:4.+'

而是使用特定版本,例如:

 compile 'com.facebook.android:account-kit-sdk:4.12.0'

使用 sdk 23 的帐户工具包中的最新版本存在问题

编辑

对于 Facebook 安卓 SDK

在您的 build.gradle 中,而不是:

 compile 'com.facebook.android:facebook-android-sdk: 4.+'

使用特定版本:

 compile 'com.facebook.android:facebook-android-sdk:4.18.0'

Facebook sdk 中的最新版本与 Android sdk 版本 23 存在问题。

原文由 rafsanahmad007 发布,翻译遵循 CC BY-SA 3.0 许可协议

在我的情况下,我使用 compile sdk 23build tools 25.0.0 刚刚更改 compile sdk 到 25 并完成..

原文由 Nilesh Deokar 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题