facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 909 forks source link

The application crashes after installing the package. #733

Open mahiraltinkaya opened 4 years ago

mahiraltinkaya commented 4 years ago

🐛 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
rshahboon1 commented 4 years ago

I crashes at my project too

ratnani1996 commented 4 years ago

@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 commented 4 years ago

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

PatrissolJuns commented 4 years ago

Faced the same issue

luanccp commented 4 years ago

Facing the same issue

TreemboLuisDev commented 4 years ago

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

luanccp commented 4 years ago

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!)

  3. 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
    }
  4. 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)'
    }
  5. Go back to your root path and in one terminal run:
    react-native start --reset-cache 
  6. In another terminal tab run:
    react-native run-android 
mansi10697 commented 3 years ago

@luanccp

Awesome 😎✋

SUMITIOS commented 3 years ago

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.

SUMITIOS commented 3 years ago

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

SUMITIOS commented 3 years ago

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 }

ghost commented 3 years ago

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 

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/> // add this line in your manifest

string file add

Facebook App ID