【问题标题】:Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'检索项目的父项时出错:找不到与给定名称“android:TextAppearance.Material.Widget.Button.Borderless.Colored”匹配的资源
【发布时间】:2017-06-27 22:02:04
【问题描述】:

我在 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>

build.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'
}

如果有人解决了这个问题,请帮忙

【问题讨论】:

    标签: android android-gradle-plugin


    【解决方案1】:

    您的编译 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 的新功能。

    最新示例的 build.gradle 与构建工具 27.0.2 -- Source

    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'
    }
    

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

    通过Answer 使用Google Maven Repository 轻松升级

    编辑

    如果您使用的是Facebook Account Kit

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

    改为使用特定版本,例如:

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

    使用 sdk 23 的 account kit 中的最新版本存在问题

    编辑

    对于Facebook Android 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 存在问题。

    【讨论】:

    • 感谢您指出并提供可能的解决方案,但它适用于compile 'com.android.support:appcompat-v7:23.4.0' @rafsanahmad007
    • 你在哪里做了这些改变
    • 在您的应用程序中 --build.gradle 文件
    • 如果您使用的是 Nativescript,只需将这些行添加到 App_Resources/Android 中的 app.gradle 中
    • 提升 buildtools 和 sdk 版本有帮助
    【解决方案2】:

    此问题是由最近版本中的回归造成的。你可以在https://github.com/facebook/react-native-fbsdk/pull/339找到解决这个问题的拉取请求

    【讨论】:

    • 谢谢 - 特别是;是您提供的链接中的 4.22.1 版本为我解决了问题(由于其他原因,我无法更改我的 android compileSdkVersion)
    • @Rod Nolan 说真的我想给你买杯啤酒或甜甜圈什么的,你的评论让我免于失去理智和头发对我来说是值得的。
    • 我发誓,在过去 5 年我遇到的所有单一问题来源中,“Facebook SDK”是最重要的。在 iOS 和 Android 以及不同的项目中,我创建的和我从其他人那里采用的项目,没有什么能比得上。因此,Android 版 Facebook SDK 的一个版本(与许多版本一样)存在问题,并且已通过硬编码的版本号解决。这就是解决方案。
    【解决方案3】:

    我找到了,我正在尝试编译使用 facebook sdk 的应用程序。我是在 2016 年 8 月做的。当我今天尝试打开它时,我遇到了同样的错误。我在我的 gradle 中有那行“编译'com.facebook.android:facebook-android-sdk:4.+'”然后我去了https://developers.facebook.com/docs/android/change-log-4x这个页面,我在成功运行这个应用程序时找到了 sdk 版本并且它是 4.14.1 然后我将该行更改为“ compile 'com.facebook.android:facebook-android-sdk:4.14.1' ”并且它起作用了。

    【讨论】:

      【解决方案4】:

      在我的情况下,我使用 compile sdk 23build tools 25.0.0 只是将 compile sdk 更改为 25 并完成..

      【讨论】:

        【解决方案5】:

        在上面提到的论坛中找到的理想答案是这样的:

        sed -i 's/facebook-android-sdk:4.+/facebook-android-sdk:4.22.1/g' ./node_modules/react-native-fbsdk/android/build.gradle
        

        这行得通

        【讨论】:

        • 编辑node modules的问题是每次全新安装,或在新设备上工作或在CI上运行时,您必须编辑节点模块文件。这不是做事的标准方式。
        【解决方案6】:

        我的解决方案(Android Studio):

        1) 使用快捷键Ctrl+Shift+Alt+S文件->项目结构

        2) 增加SDK“编译SDK版本”的等级。

        【讨论】:

          猜你喜欢
          • 2017-10-27
          • 2014-06-04
          • 2017-02-10
          • 2017-09-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-12-27
          相关资源
          最近更新 更多