Search code examples
androidreact-nativereact-native-fbsdk

react-native-fbsdk 0.8.0 package com.facebook.reactnative.androidsdk does not exist


I've tried to upgrade the react-native-fbsdk from 0.7.0 to 0.8.0 but the react-native run-android command does not working anymore.

:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). C:\Dev\react-native\imnews\android\app\src\main\java\com\imnews\MainApplication.java:10: error: package com.facebook.reactnative.androidsdk does not exist import com.facebook.reactnative.androidsdk.FBSDKPackage; ^ C:\Dev\react-native\imnews\android\app\src\main\java\com\imnews\MainApplication.java:43: error: cannot find symbol new FBSDKPackage(mCallbackManager), ^ symbol: class FBSDKPackage

This is the reason why I'd like to upgrade to this version: Ios version of app works, but Android fails due to no suitable constructor found for AccessToken for React Native App

I've noticed, there is no build directory in node_modules/react-native-fbsdk/android.

Used react-native version: [email protected]

Could somebody help me please?


Solution

  • The official bug report helped me to fix this issue: https://developers.facebook.com/support/bugs/260814197942050/?disable_redirect=0

    copy-pasted the resolution from the link above - you need to add this to android/build.gradle:

    def versionOverrides = [
            "com.facebook.android:facebook-android-sdk": "4.37.0",
    ]
    
    allprojects {
            repositories {
                    ...
            }
            configurations.all {
                    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                            def overrideVersion = versionOverrides[details.requested.group + ":" + details.requested.name]
    
                            if (overrideVersion != null && details.requested.version != overrideVersion) {
                                    details.useVersion overrideVersion
                            }
                    }
            }
    }