React-native-fbsdk: error: package com.facebook.reactnative.androidsdk does not exist import com.facebook.reactnative.androidsdk.FBSDKPackage;

Created on 16 Jul 2019  路  9Comments  路  Source: facebook/react-native-fbsdk

馃悰 Bug Report

I am trying to use the version "react-native-fbsdk": "^0.10.1" in a React Native "0.59.9" project. I've followed the steps the FBSDK Repo and FB Getting Started Guide but when I run the react-native run-android I get the following error:

error: package com.facebook.reactnative.androidsdk does not exist import com.facebook.reactnative.androidsdk.FBSDKPackage; 

I have already ran react-native link

Expected Behavior

According to the documentation, I should be able to run the project at this point

Code Example

This is my MainApplication.java

package com.<APP NAME>;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.dylanvann.fastimage.FastImageViewPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new FBSDKPackage(),
          new MapsPackage(),
          new FastImageViewPackage(),
          new VectorIconsPackage(),
          new RNGestureHandlerPackage()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

Environment

React Native Environment Info:
System:
OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Memory: 226.26 MB / 11.61 GB
Shell: 5.4.2 - /usr/bin/zsh
Binaries:
Node: 10.15.1 - ~/.nvm/versions/node/v10.15.1/bin/node
Yarn: 1.17.3 - /usr/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.1/bin/npm
SDKs:
Android SDK:
API Levels: 23, 26, 28
Build Tools: 27.0.3, 28.0.3
System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
react-native-cli: 2.0.1

Most helpful comment

Im using rn 0.60 and I added:

  implementation project(':react-native-fbsdk')
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

and in settings.gradle

include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')

In package.json: "react-native-fbsdk": "^1.0.1"

And it seems that the instance new FBSDKPackage is not longer using mCallbackManager, in fact is being add it with auto link in packagelist

All 9 comments

This isn't a solution to the problem or a solution that'll work for everyone, but I suggest installing the SDK with cocoapods. react-native link is so broken, it does more harm than good. Delete project_root/ios/[Podfile.lock, Pods], add pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk' to your target's body section, run pod install, run "clean build folder" with xcode, and try to build the project. You might progress forward to untangling dependencies... GOOD LUCK!!!

I have the same issue, in my case with android, I have make link step according to https://github.com/facebook/react-native-fbsdk#31-android but I have not able to run my project, may somebody help me?

I had this problem too - I was able to fix it by adding this to the dependencies line in android/app/build.gradle:

implementation project(':react-native-fbsdk')

Hope it helps you.

Hello @slimethefrozen, I tried that and unfortunately, it didn't work. Also, @kessler9, I tried that as well but with no luck

@AlexxMart can you show me your error? I might have seen it before. I can't promise anything but I'd love to put you out of your misery if I've seen the error before.

Sorry that didn't help - worked for me, but I guess you have a different issue.

I found the differences by making a simple FBSDK project, and then comparing the gradle files and package.json - just make sure your new test project is using the same RN version as the project with the error.

@slimethefrozen Sorry it took a few days for me to read this. I will create a new RN project (react-native: 0.59.9) with the latest FBSDK version to see if it works there and compare the Gradle Files

Sure thing @kessler9 I will reproduce the error and see what comes up after trying the suggestion made by @slimethefrozen to see if it works or anything changes

Im using rn 0.60 and I added:

  implementation project(':react-native-fbsdk')
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

and in settings.gradle

include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')

In package.json: "react-native-fbsdk": "^1.0.1"

And it seems that the instance new FBSDKPackage is not longer using mCallbackManager, in fact is being add it with auto link in packagelist

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emroot picture emroot  路  5Comments

smzeeshan91 picture smzeeshan91  路  4Comments

peymancyb picture peymancyb  路  6Comments

sibelius picture sibelius  路  4Comments

vladotg picture vladotg  路  5Comments