【问题标题】:react-native run-android compile fails: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'react-native run-android 编译失败:找不到与给定名称'android:TextAppearance.Material.Widget.Button.Colored'匹配的资源
【发布时间】:2018-05-19 08:40:29
【问题描述】:

当运行react-native run-android 时,它会抛出以下错误:

/Users/waltermonecke/Code_Projects/reactNative/lisdo/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:3: AAPT:检索项目的父项时出错:未找到匹配的资源 给定的名字 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'。

/Users/waltermonecke/Code_Projects/reactNative/lisdo/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:4: AAPT:检索项目的父项时出错:未找到匹配的资源 给定的名字 'android:TextAppearance.Material.Widget.Button.Colored'。

/Users/waltermonecke/Code_Projects/reactNative/lisdo/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:3: 错误:检索项目的父项时出错:找不到资源 匹配给定的名称 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'。

/Users/waltermonecke/Code_Projects/reactNative/lisdo/android/app/build/intermediates/res/merged/debug/values-v24/values-v24.xml:4: 错误:检索项目的父项时出错:找不到资源 匹配给定的名称 'android:TextAppearance.Material.Widget.Button.Colored'。

我以为这个错误与this关于构建版本SDK的问题有关,但我尝试了一切都没有成功。

我已经进行了大约 6 个小时,真的需要一些帮助。

build.gradle:

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.lisdo"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
...
}

dependencies {
compile project(':react-native-google-places')
compile project(':react-native-fetch-blob')
compile project(':react-native-image-picker')
compile project(':react-native-vector-icons')
compile project(':react-native-fbsdk')
compile project(':react-native-linear-gradient')
compile project(':react-native-video')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"  // From node_modules
}

【问题讨论】:

  • 你有没有得到这个答案?我现在遇到了同样的问题
  • 我也是在升级了一些依赖项(react、react-native 等)之后,必须找到哪个使这个

标签: android react-native


【解决方案1】:

检查 create-react-native 包上的 this comment,似乎某些模块使用的本机模块版本不是您在应用程序的本机端使用的版本,因此,从库中,它不能获取资产。

将此行添加到android/build.gradle 文件的末尾,在您的 RN 目录下。

subprojects { 
     afterEvaluate { 
         project -> if (project.hasProperty("android")) { 
             android { 
                 compileSdkVersion 26 
                buildToolsVersion '26.0.2' 
             } 
         } 
     } 
 }

它只是将版本强制为您设置的版本。

这是android/build.gradle 不是android/app/build.gradle

【讨论】:

    猜你喜欢
    • 2017-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多