问题
I'm having issues building my android folder with react-native run-android after installing the fbsdk library and following all the steps to properly link it. Below is my error message.
I already tried to change my default sdk version from 23 to 27.0.1 which allowed me to have a more detailed error message since before I would only get failed to build aapp.
Any idea how to fix this? It works properly on ios.
> Task :react-native-fbsdk:compileDebugJavaWithJavac FAILED
/Users/hugohyz/code/hugoh1995/dogtime_react/DogtimeReactInit/node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/FBAppEventsLoggerModule.java:209: error: cannot find symbol
@ReactMethod(isBlockingSynchronousMethod = true)
^
symbol: method isBlockingSynchronousMethod()
location: @interface ReactMethod
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/hugohyz/code/hugoh1995/dogtime_react/DogtimeReactInit/node_modules/react-native-fbsdk/android/src/main/java/com/facebook/reactnative/androidsdk/Utility.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-fbsdk:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
76 actionable tasks: 1 executed, 75 up-to-date
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
回答1:
I solved it by updating fbsdk to 0.8.0
react-native install react-native-fbsdk@0.8.0
Note: This will link the library. It may cause dual entries in your corresponding files, which you have to remove manually.
回答2:
Ok so I managed to fix the fbsdk related issue. Apparently I was missing the following code inside android/build.graddle
allprojects {
repositories {
...
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
...
I'm now faced with another issue tho so I'll open another thread.
It's important not to replace existing maven when adding new maven to the repositories apparently.
回答3:
Change your version of facebook-android-sdk to 4.37.0 on node_modules/react-native-fbsdk/android/build.gradle
compile 'com.facebook.android:facebook-android-sdk:4.37.0'
react-native-fbsdk error can't run react-native run-android
来源:https://stackoverflow.com/questions/48546467/react-native-fbsdk-issue-task-react-native-fbsdkcompiledebugjavawithjavac-fa