【问题标题】:react-native-fbsdk error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'react-native-fbsdk 错误:找不到与给定名称匹配的资源:attr 'android:keyboardNavigationCluster'
【发布时间】:2018-05-25 05:18:05
【问题描述】:

android/app/build.gradle 我的 react-native 项目中

...
compileSdkVersion 26
    buildToolsVersion "26.0.1"

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

...

dependencies {
    compile project(':react-native-fbsdk')
    compile project(':react-native-vector-icons')
    compile project(':react-native-splash-screen')
    compile project(':react-native-spinkit')
    compile project(':react-native-orientation')
    compile project(':react-native-maps')
    compile project(':react-native-android-sms-listener')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:26+"
    compile "com.android.support:design:26+"
    compile "com.android.support:recyclerview-v7:26+"
    compile "com.android.support:cardview-v7:26+"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile("com.crashlytics.sdk.android:crashlytics:2.8.0@aar") {
        transitive = true;
    }
}
...

但我总是得到

<mypath> .../node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

<mypath> .../node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.


:react-native-fbsdk:processReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-fbsdk:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

【问题讨论】:

  • 你应该在所有依赖 build.gradle 文件中更改 compileSdkVersion = 26buildToolsVersion = '26.0.1' @Sunrising
  • 我应该在 node_modules 中编辑文件吗? @SyedZainAli
  • 是的,您必须更新 node_modules/fb SDK 中的文件
  • 我只是不认为这是正确的方法,对不起
  • link 这个相同的问题和 解决方案也相同 。你一定要看。我认为解决方案是正确的。如果您有更好的解决方案,您必须与我们分享。

标签: react-native android-gradle-plugin react-native-fbsdk


【解决方案1】:

转到 React-Native 项目android/build.gradle 文件并将 fbsdk 版本限制为 4.28.0

allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.28.0'
            }
        }
    }
}

如果您遇到如下错误:

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

你可以试试:

allprojects {
    repositories {
        ...
        configurations.all {
            resolutionStrategy {
                force 'com.facebook.android:facebook-android-sdk:4.22.1'
            }
        }
    }
}

来源:rafaesc

【讨论】:

  • 只要确保您使用当前的 SDK 版本,这些版本在 app/build.gradle - compileSdkVersion 26 buildToolsVersion "26.0.1" 中设置。如果仍然抛出错误,请将 maven { url "https://maven.google.com" } 添加到 build.gradle
  • 不敢相信最新版本还没有修复这个问题,非常感谢!
【解决方案2】:

你去 YOUR_PROJECT/node_modules/react-native-fbsdk/android/build.gradle

寻找第 19 行:

dependencies {
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
    compile('com.facebook.android:facebook-android-sdk:4.+')
}

将 compile('com.facebook.android:facebook-android-sdk:4+') 更改为 compile('com.facebook.android:facebook-android-sdk:4.28.0')

对我有用

【讨论】:

  • 是的!它对我有用。非常感谢,你为我节省了很多时间
  • 谢谢。这也对我有用。现在,虽然说Configuration with name 'default' not found,但我收到了另一条错误消息。
  • 这是一个糟糕的解决方案,它只会在您更新依赖项并且 node_modules 被覆盖之前有效。还假设您的 node_modules 被排除在源代码管理之外,其他任何人都无法运行您的项目。
猜你喜欢
  • 2018-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多