在启动时反应原生Android崩溃-Google Play服务

时间:2019-03-03 18:53:27

标签: javascript android react-native gradle build.gradle

我的应用在Android上启动时崩溃。我正在使用Firebase和React-Native-Maps。我搜索了与此主题相关的每个主题,并了解到它很可能与我的Google Play服务有所不同。  但是我仍然不知道如何解决它。实际上,基于那些软件包的当前版本,我实际上应该将其设置为哪个版本。  如果有人可以解释我如何理解我需要的Google Play服务版本以及原因,我将非常感激。另外,每当我尝试将其更改为较新版本(16.0.1)时,它都会抱怨找不到它。我认为有某种方法可以为整个应用设置正确的版本,但是我仍然不知道如何做到这一点,为什么我只将build.gradle GooglePlayServices更改为16.0.1也不起作用。

Logcat

E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.TestApp, PID: 11804
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/internal/zzbfm;
        at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39)
        at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:770)
        at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:170)
        at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:53)
        at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:128)
        at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:125)
        at com.facebook.react.LazyReactPackage$2$1.next(LazyReactPackage.java:102)
        at com.facebook.react.LazyReactPackage$2$1.next(LazyReactPackage.java:89)
        at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:44)
        at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1212)
        at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1182)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1120)
        at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.internal.zzbfm" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.TestApp-nXhNPbcz9BGaG9JH-NkdMg==/base.apk"],nativeLibraryDirectories=[/data/app/com.TestApp-nXhNPbcz9BGaG9JH-NkdMg==/lib/x86, /data/app/com.TestApp-nXhNPbcz9BGaG9JH-NkdMg==/base.apk!/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39) 
        at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:770) 
        at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:170) 
        at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:53) 
        at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:128) 
        at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:125) 
        at com.facebook.react.LazyReactPackage$2$1.next(LazyReactPackage.java:102) 
        at com.facebook.react.LazyReactPackage$2$1.next(LazyReactPackage.java:89) 
        at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:44) 
        at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1212) 
        at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1182) 
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1120) 
        at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123) 
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943) 
        at java.lang.Thread.run(Thread.java:764) 

build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "11.8.0"
        androidMapsUtilsVersion = "0.5+"
    }
    repositories {
        google()
        //mavenLocal()        
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.0.2'  

    }
}

app / build.gradle

 dependencies {
        implementation project(':react-native-firebase')
        implementation project(':react-native-gesture-handler')
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
        implementation "com.facebook.react:react-native:+"  // From node_modules
        implementation project(':react-native-linear-gradient')
        implementation project(':react-native-maps') 
        implementation "com.google.android.gms:play-services-base:16.0.1"
        implementation "com.google.firebase:firebase-core:16.0.6"    
}

非常感谢 卢克

0 个答案:

没有答案