可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am trying to build my react-native project and using react-native fbsdk.
However, I get these errors:
/home/luiz/MYP/app/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
/home/luiz/MYP/app/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
/home/luiz/MYP/app/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
/home/luiz/MYP/app/node_modules/react-native-fbsdk/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
:react-native-fbsdk:processReleaseResources FAILED
My current OS is Linux Elementary 0.4.1 Loki x64.
I am using react-native@0.37.0 and, because of this, react-native-fbsdk@0.4.0.
I've already tried:
cd android && ./gradlew clean
delete the project and re npm install
it
and try in Android API's 23 and 24.
回答1:
After digging into gradle, I came up with following solution.
Key is to exclude facebook-android-sdk
required by react-native-fbsdk
and pull in desired (working) version on facebook-android-sdk
module - preferably without modifying anything in node_modules folder.
Fortunately, gradle offers this.
// android/app/build.gradle
dependencies {
compile(project(':react-native-fbsdk')){
exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
}
compile "com.facebook.android:facebook-android-sdk:4.22.1"
}
回答2:
Apparently facebook has updated their sdk yesterday and the latest (4.23.0) sdk may have a bug or something.
You can resolve this by Changing your node_modules\react-native-fbsdk\android\build.gradle from:
compile('com.facebook.android:facebook-android-sdk:4.+')
To:
compile('com.facebook.android:facebook-android-sdk:4.22.1')
I'm no gradle guy so if someone knows of a better way of forcing the version from parent gradle.build, please comment and I'll update the answer.
** EDIT **
@Andreyco managed to solve this without changing node_modules. You can scroll down to his answer or click here.
Also, as notified by @JuanJoseTugores there's a pull request in react-native-fbsdk waiting to be approved, so you can check the bug's progress and be notified when it's resolved.
** Another Update **
Facebook closed the bug that was opened for them regarding this issue, saying they fixed the sdk. So now all the workarounds can be removed.
Apparently FB still not solved this. We just upgraded to RN 0.44 & FB 0.6.0
回答3:
I was able to resolve this without modifying files under node_modules/...
. I upgraded our react-native-fbsdk
version to 0.6.0
and then add this to our application's build.gradle
file to pin facebook-android-sdk
at version 4.22.1
:
project(':react-native-fbsdk') {
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.22.1'
}
}
}
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.22.1'
...
}
}
Edit: We are building with:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
...
}
回答4:
I just encountered this error. First, RN Facebook SDK v.0.6.0 only works for react-native >= 0.44.0
, so you have to update your dependency in package.json
to react-native: ^0.44.0
. Then go to Android build.gradle
file and make this changes: compileSdkVersion 25
and compile "com.android.support:appcompat-v7:25.0.0"
回答5:
For those who are looking for make it work using RN 0.42 which by now is the one with react version stable you may need to use the Facebook SDK 4.18.0 "com.facebook.android:facebook-android-sdk:4.18.0"
which is the one that was released by the time that react-native-fbsdk@0.5.0
was released, otherwise you may be ending up with the issue: https://developers.facebook.com/bugs/1712442065726889/
Besides, if you are getting hard times to force the facebook sdk to be what you need try this:
android/app/build.gradle
...
dependencies {
compile project(':react-native-fbsdk')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.facebook.android:facebook-android-sdk:[4.18.0)"
}
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
project(':react-native-fbsdk') {
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.18.0'
}
}
}
...
allprojects {
repositories {
...
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.18.0'
}
}
}
}
回答6:
this fixed for me
in android/build.gradle
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
}
}
}
}
回答7:
As you can see here there is patches incoming,
https://github.com/facebook/react-native-fbsdk/pull/339
https://github.com/facebook/react-native-fbsdk/pull/338
in the meantime if you're using react-native-fbsdk v0.5 you could do
yarn add react-native-fbsdk@https://github.com/tugorez/react-native-fbsdk
I've applied the suggested changes and it's working :) but please be aware I'll no support this and wont keep it update so... as soon as you can you should go back to the official library.