1

I'm installing fbsdk to my react-native apps, i ran the following commands

npm install react-native-fbsdk@0.6.0 --save

react-native link react-native-fbsdk

After successfully installed i run react-native run-android and i got the following resultenter image description here

Here is my changes

In MainApplication.js

package com.ddc;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;

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

public class MainApplication extends Application implements ReactApplication {

  private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

  protected static CallbackManager getCallbackManager() {
    return mCallbackManager;
  }

  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 VectorIconsPackage(),
          new FBSDKPackage(mCallbackManager)
      );
    }
  };

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

  @Override
  public void onCreate() {
    super.onCreate();
    FacebookSdk.sdkInitialize(getApplicationContext());
    // If you want to use AppEventsLogger to log events.
    AppEventsLogger.activateApp(this);
  }
}

In MainActivity.js

package com.ddc;

import com.facebook.react.ReactActivity;
import android.content.Intent;

public class MainActivity extends ReactActivity {

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
    }

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "DDC";
    }
}

After that i modify the build.gradle, because after i run react-native link react-native-fbsdk it doesn't modify the file

repositories {
  mavenCentral()
}

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

How can i accept the agreement ?

Darren Lau
  • 1,995
  • 4
  • 25
  • 40
  • You don't mention doing any of the [configuration steps](https://github.com/facebook/react-native-fbsdk#3-configure-native-projects). Did you follow all of the instructions to the end? – Michael Cheng Jun 27 '17 at 19:28
  • @MichaelCheng I've updated my question, could you please help to review and advise me on this ? – Darren Lau Jul 04 '17 at 15:28

2 Answers2

0

your ANDROID_HOME variable is not properly set. fix that.

hakimkal
  • 90
  • 1
  • 12
0

Solution via console using sdkmananger:

yes | sudo sdkmanager --licenses

Source - Automatically accept all SDK licences

blackchestnut
  • 1,259
  • 10
  • 15