反应原生 fbsdk 问题 - 任务:react-native-fbsdk:compileDebugJavaWithJavac FAILED

React native fbsdk issue - Task :react-native-fbsdk:compileDebugJavaWithJavac FAILED

我在安装 fbsdk 库并按照所有步骤正确 link 后使用 react-native 运行-android 构建我的 android 文件夹时遇到问题它。以下是我的错误信息。

我已经尝试将我的默认 sdk 版本从 23 更改为 27.0.1,这让我可以得到更详细的错误消息,因为之前我只会构建应用程序失败。

知道如何解决这个问题吗?它在 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

好的,我设法解决了与 fbsdk 相关的问题。显然我在 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"
        }
      ...

我现在面临另一个问题,所以我将打开另一个线程。

显然,在向存储库添加新的 maven 时,不要替换现有的 maven 很重要。

I solved it by updating fbsdk to 0.8.0

react-native install react-native-fbsdk@0.8.0

注意:这将 link 库。这可能会导致您的相应文件出现双重条目,您必须手动删除这些条目。

在 node_modules/react-native-fbsdk/android/build.gradle

将您的 facebook-android-sdk 版本更改为 4.37.0
compile 'com.facebook.android:facebook-android-sdk:4.37.0'

react-native-fbsdk error can't run react-native run-android