2

I have done all the settings that are given in this link and also this link. But I am getting the following errors when I try to run my project,

/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainActivity.java:17: error: cannot find symbol
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
                                                                  ^
  symbol:   class Intent
  location: class MainActivity
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:11: error: cannot find symbol
import com.facebook.CallbackManager;
                   ^
  symbol:   class CallbackManager
  location: package com.facebook
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:12: error: cannot find symbol
import com.facebook.FacebookSdk;
                   ^
  symbol:   class FacebookSdk
  location: package com.facebook
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:13: error: package com.facebook.reactnative.androidsdk does not exist
import com.facebook.reactnative.androidsdk.FBSDKPackage;
                                          ^
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:14: error: package com.facebook.appevents does not exist
import com.facebook.appevents.AppEventsLogger;
                             ^
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:21: error: cannot find symbol
  private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
                 ^
  symbol:   class CallbackManager
  location: class MainApplication
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:23: error: cannot find symbol
  protected static CallbackManager getCallbackManager() {
                   ^
  symbol:   class CallbackManager
  location: class MainApplication
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:21: error: package CallbackManager does not exist
  private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
                                                                   ^
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:38: error: cannot find symbol
          new FBSDKPackage(mCallbackManager)
              ^
  symbol: class FBSDKPackage
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:52: error: cannot find symbol
    FacebookSdk.sdkInitialize(getApplicationContext());
    ^
  symbol:   variable FacebookSdk
  location: class MainApplication
/mnt/2EB2BF06B2BED217/Freelancing/yasco/sg/saZen/mobile/sazenappmobile/SaZen/android/app/src/main/java/com/sazen/MainApplication.java:54: error: cannot find symbol
    AppEventsLogger.activateApp(this);
    ^
  symbol:   variable AppEventsLogger
  location: class MainApplication
11 errors
:app:compileDebugJavaWithJavac FAILED

Currently I am using "16.0.0-alpha.12" version of react.

4 Answers 4

3

My project compiles with the latest package versions, using buildToolsVersion 25.0.3

build.gradle

compileSdkVersion 25
buildToolsVersion "25.0.3"

build.gradle defaultConfig

targetSdkVersion 25

build.gradle dependencies

compile "com.android.support:appcompat-v7:25.0.3"

The documentation says

If your react-native version is below 0.29.0

but it throws error saying cannot find symbol Intent so...

MainActivity.java

import android.content.Intent;
1

if you are using the latest react-native downgrade to 0.46.4, the latest version has some breaking changes that affect many native packages.

Also use [email protected] as it is still compiled with buildToolsVersion 23

Follow the steps again and it should work

I spend quite a few hours recently trying to make this work and only downgrading to these version solved the issues I was encountering.

1
  • Thanks for your response, I tried degrading the version and then tried the steps mentioned in the above mentioned link. But still stumbling into the same issue. I strongly feel I am missing some step. I am not getting what wrong I am doing. Commented Aug 8, 2017 at 12:50
1

You need to import android.content.Intent in MainActivity.java:

import android.content.Intent;

in MainApplication.java:

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

The final version of my gradle, which worked for me, looks like below,

android {
    compileSdkVersion 24
...
repositories {
    mavenCentral()
}

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

Observe these lines in the dependencies,

dependencies {
    compile "com.android.support:appcompat-v7:24.2.1"
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'

and the compileSDKVersion must same as the support and hence it must be,

android {
    compileSdkVersion 24

These were the main things which held me for these many days.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.