使用“ E / AndroidRuntime:致命异常:mqt_native_modules”使React Native Android App崩溃

时间:2019-11-13 14:16:40

标签: android react-native react-native-android react-native-firebase react-native-maps

在现有项目中安装并配置react-native-maps@react-native-firebase/app后,我的应用崩溃了。

环境信息

OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
Memory: 2.08 GB / 11.90 GB
Binaries:
Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.9.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
SDKs:
Android SDK:
  API Levels: 23, 25, 26, 27, 28
  Build Tools: 23.0.1, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.1, 28.0.2, 28.0.3
  System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5900203
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4

我的部分应用依赖项:

"@react-native-firebase/app": "^6.0.3",
"react-native-maps": "0.26.1",

复制步骤

我通过Aandroid studio进行了调试,并得到以下错误

  

---------崩溃开始   11-13 15:00:24.209 4709-4746 / com.melk.android E / Android运行时:致命异常:mqt_native_modules       流程:com.melk.android,PID:4709       java.lang.NoClassDefFoundError:com.google.android.gms.maps.GoogleMapOptions           在com.airbnb.android.react.maps.AirMapManager中。(AirMapManager.java:60)           在com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:40)           在com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:782)           在com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:184)           在com.facebook.react.CoreModulesPackage.getModule(CoreModulesPackage.java:152)           在com.facebook.react.TurboReactPackage $ ModuleHolderProvider.get(TurboReactPackage.java:122)           在com.facebook.react.TurboReactPackage $ ModuleHolderProvider.get(TurboReactPackage.java:110)           在com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:188)           在com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:153)           在com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:148)           在com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:479)           在com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:466)           在com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:31)           在com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1054)           在com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1012)           在com.facebook.react.ReactInstanceManager.access $ 1400(ReactInstanceManager.java:125)           在com.facebook.react.ReactInstanceManager $ 5 $ 2.run(ReactInstanceManager.java:972)           在android.os.Handler.handleCallback(Handler.java:739)           在android.os.Handler.dispatchMessage(Handler.java:95)           在com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:26)           在android.os.Looper.loop(Looper.java:148)           在com.facebook.react.bridge.queue.MessageQueueThreadImpl $ 4.run(MessageQueueThreadImpl.java:225)           在java.lang.Thread.run(Thread.java:818)

可复制的示例代码

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.4.2")

        classpath 'com.google.gms:google-services:4.2.0'
    }
}

1 个答案:

答案 0 :(得分:0)

如下修改android/app/build.gradle

dependencies {
    implementation "com.facebook.react:react-native:+"  // From node_modules


    - implementation 'com.google.android.gms:play-services-base:10.0.1'  //remove this line
    - implementation 'com.google.android.gms:play-services-maps:10.0.1'  //remove this line
    + implementation 'com.google.android.gms:play-services-base:+'       //add this line
    + implementation 'com.google.android.gms:play-services-maps:+'       //add this line

}