2

我已经完成了这个链接和这个链接中给出的所有设置。但是当我尝试运行我的项目时出现以下错误,

/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

目前我正在使用“16.0.0-alpha.12”版本的反应。

4

4 回答 4

3

我的项目使用最新的包版本编译,使用 buildToolsVersion 25.0.3

构建.gradle

compileSdkVersion 25
buildToolsVersion "25.0.3"

build.gradle defaultConfig

targetSdkVersion 25

build.gradle 依赖项

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

文件说

如果您的 react-native 版本低于 0.29.0

但它抛出错误说找不到符号意图所以......

MainActivity.java

import android.content.Intent;
于 2017-11-03T07:07:06.103 回答
1

如果您使用最新的 react-native 降级到 0.46.4,最新版本有一些影响许多本机软件包的重大更改。

也使用 react-native-fbsdk@0.6.0 因为它仍然使用 buildToolsVersion 23 编译

再次按照步骤操作,它应该可以工作

我最近花了好几个小时试图完成这项工作,只有降级到这些版本才能解决我遇到的问题。

于 2017-08-08T09:41:43.120 回答
1

您需要在 MainActivity.java 中导入 android.content.Intent:

import android.content.Intent;

在 MainApplication.java 中:

import com.facebook.CallbackManager;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.FacebookSdk;
于 2018-04-04T09:45:41.527 回答
0

对我有用的我的 gradle 的最终版本如下所示,

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)'
}

在依赖项中观察这些行,

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

并且 compileSDKVersion 必须与支持相同,因此它必须是,

android {
    compileSdkVersion 24

这些是我这几天的主要事情。

于 2017-08-10T05:32:11.667 回答