React-native-fbsdk: The application crashes after installing the package.

Created on 10 Apr 2020  ยท  12Comments  ยท  Source: facebook/react-native-fbsdk

๐Ÿ› Bug Report

Hello friends. After loading with npm install react-native-fbsdk, the application crashed after the compilation is completed. When I run it in development mode, I get the following error. How can I solve the problem?


The following edits were made
Settings.gradle
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-fbsdk/android')
app/build.gradle

dependencies {
  compile project(':react-native-fbsdk')
  compile fileTree(dir: "libs", include: ["*.jar"])
  compile "com.android.support:appcompat-v7:23.0.1"
  compile "com.facebook.react:react-native:+"  // From node_modules
}

image

To Reproduce

Expected Behavior


The production build completes with no error.

Code Example

Environment

OS : Windows 10
Android Studio : 3.6.1
React : RN 0.62.0
Gradle Plugin V.: 3.6.1
Gradle V. : 6.0.1

Most helpful comment

@luanccp

Awesome ๐Ÿ˜Žโœ‹

All 12 comments

I crashes at my project too

@mahiraltinkaya you are not linking the module correctly. Try manual linking the library on Android, everything is mention in the README file of the repository. If you are using react-native version 0.60+ no need to manually link the module. I am assuming you have already configured your facebook app on https://developer.facebook.com/

@mahiraltinkaya you are not linking the module correctly. Try manual linking the library on Android, everything is mention in the README file of the repository. If you are using react-native version 0.60+ no need to manually link the module. I am assuming you have already configured your facebook app on https://developer.facebook.com/

I am using 0 62 version. I did not import to any page. When I just install it the application terminates and does not open. I can't do debug.

Faced the same issue

Facing the same issue

I am having the same problem, have you solved this?

I fixed my problem!

  1. Uninstall the app from your emulator or device
  2. change directory to android and run:
./gradlew clean 

(use another command if you're at windows, google it!)

  1. Go to android/app/build.gradle and add:
    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true // this line will fix
    }
  1. Check in the same file your dependencies:
dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
    }
  1. Go back to your root path and in one terminal run:
react-native start --reset-cache 
  1. In another terminal tab run:
react-native run-android 

@luanccp

Awesome ๐Ÿ˜Žโœ‹

I face the same issue exactly like @mahiraltinkaya on mac with React Native 0.62.2 or above. The issue starts just after adding the yarn add react-native-fbsdk without making any other changes to any file.
I already have multiDexEnabled as true before installing this package. I have tried solution by @luanccp but no luck.

I face the same issue exactly like @mahiraltinkaya on mac with React Native 0.62.2 or above. The issue starts just after adding the yarn add react-native-fbsdk without making any other changes to any file.
I already have multiDexEnabled as true before installing this package. I have tried solution by @luanccp but no luck.

On Xiomi devices, I can see the builds crash logs as follows:
`
java.lang.NullPointerException: Attempt to invoke interface method 'int com.facebook.react.bridge.UIManager.addRootView(android.view.View, com.facebook.react.bridge.WritableMap, java.lang.String)' on a null object reference

`
WhatsApp Image 2020-09-24 at 18 35 24

I am using 0 62 version. I did not import to any page. When I just install it the application terminates and does not open. I can't do debug.

I had exactly the same problem as mentioned @mahiraltinkaya , the real issue behind it is setup of AndroidManifest.xml and Strings.xml properly.
So, make sure its done the right way.
In addition to this I had to install required version of NDK for android because I was facing
https://github.com/gradle/gradle/issues/12440#issue-576216391 issue too.

So I added following in my android/app/build.gradle to build successfully

android { ndkVersion "21.3.6528147"<----your installed NDK version here }

Solved issues after adding this line and rebuild project

implementation 'com.facebook.android:facebook-android-sdk:8.1.0' // add this line in your app module  under dependencies

android:value="@string/facebook_app_id"/> // add this line in your manifest

string file add
Facebook App ID

Was this page helpful?
0 / 5 - 0 ratings