Search code examples
androidreactjsandroid-studioreact-nativefbsdk

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


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

Solution

  • 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.