React native fbsdk:在Android上启用multidex React native应用时无法调用FBGraphRequest.start

时间:2018-11-13 13:37:05

标签: android react-native multidex android-multidex react-native-fbsdk

我正在对Android上的本机应用程序进行编程。由于我的应用程序具有一些第三方库,因此我必须在Android上启用超过65536种方法的multidex。

我的android / app / build.gradle

android {
defaultConfig {
    minSdkVersion 16 
    targetSdkVersion 25
    multiDexEnabled true
}}

dependencies {
  compile 'com.android.support:multidex:1.0.3'
}

我成功构建了应用程序。但是在我的应用程序中,我安装了react-native-fbsdk以便通过Facebook登录。当我只用facebook按钮按下登录时出现错误:

11-13 20:20:13.707 15581-15640/com.fahasa.android.fahasa E/unknown:ReactNative: Exception in native call
java.lang.RuntimeException: Could not invoke FBGraphRequest.start
    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
    at android.os.Looper.loop(Looper.java:136)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
    at java.lang.Thread.run(Thread.java:841)
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:363)
    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) 
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
    at android.os.Handler.handleCallback(Handler.java:733) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
    at android.os.Looper.loop(Looper.java:136) 
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) 
    at java.lang.Thread.run(Thread.java:841) 
 Caused by: java.lang.NoSuchMethodError: com.facebook.AccessToken.<init>
    at com.facebook.reactnative.androidsdk.FBGraphRequestModule.setConfig(FBGraphRequestModule.java:158)
    at com.facebook.reactnative.androidsdk.FBGraphRequestModule.buildRequest(FBGraphRequestModule.java:136)
    at com.facebook.reactnative.androidsdk.FBGraphRequestModule.start(FBGraphRequestModule.java:123)
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:363) 
    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162) 
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
    at android.os.Handler.handleCallback(Handler.java:733) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31) 
    at android.os.Looper.loop(Looper.java:136) 
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194) 
    at java.lang.Thread.run(Thread.java:841) 

我的package.json

"dependencies": {
"async": "^2.5.0",
"bugsnag-react-native": "^2.2.0",
"he": "^1.1.1",
"moment": "^2.18.1",
"oauth-1.0a": "^2.1.0",
"prop-types": "^15.5.10",
"react": "16.0.0-alpha.12",
"react-native": "0.48.3",
"react-native-camera": "^0.13.0",
"react-native-datepicker": "^1.4.7",
"react-native-device-info": "^0.11.0",
"react-native-drawer": "^2.3.0",
"react-native-dropdown-menu": "^2.0.0",
"react-native-fast-image": "^1.0.0",
"react-native-fbsdk": "^0.6.1",
"react-native-firebase": "1.1.2",
"react-native-image-progress": "^1.0.1",
"react-native-keyboard-aware-scroll-view": "^0.2.7",
"react-native-modal-dropdown": "^0.4.2",
"react-native-navbar": "^1.5.0",
"react-native-onesignal": "^3.0.6",
"react-native-progress": "^3.4.0",
"react-native-push-notification": "^2.2.1",
"react-native-root-toast": "^1.0.3",
"react-native-router-flux": "^3.37.0",
"react-native-scrollable-tab-view": "^0.8.0",
"react-native-swiper": "^1.5.12",
"react-native-vector-icons": "^4.0.0",
"react-native-webview-android": "^1.1.17",
"react-navigation": "^1.0.0-beta.11",
"react-redux": "^5.0.3",
"redux": "^3.7.2",
"redux-logger": "^2.6.1",
"redux-persist": "^4.9.1",
"redux-thunk": "^2.1.0"

},

请帮助我。 非常感谢!

2 个答案:

答案 0 :(得分:0)

做     npm安装 从android studio或Build并重新运行android应用     npm运行android

答案 1 :(得分:0)

尝试此版本。

implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

取决于您的app / build.gradle文件。