如何修复DexPathList上缺少的类com.google.android.gms.common.internal.zzbq

时间:2019-05-08 17:30:42

标签: android-studio react-native

我无法终生让我的React Native应用程序在android上运行。我已经阅读了关于类似错误的所有SO答案,但没有任何效果。它会进行同步和编译,但是一旦启动,它就会崩溃,并显示以下我粘贴在下面的错误消息。

我尝试了以下

  1. 启用Multidex支持。因为我使用的是minSDKVersion = 21,所以根据文档要做的所有事情都是在build.gradle项目中将“ MultiDexEnabled true”设置为
  2. 最初,我已经声明了对firebase-core的依赖,例如:'com.google.firebase:firebase-core:16.0.1',并应用了gms.google-services插件,所有这些都根据firebase文档确定。我遇到了很多冲突,因此我删除了这两行,希望react-native-firebase可以为我处理所有这一切。
    根据firebase文档。
  3. 根据google文档,您不再需要确保播放服务库的版本相同,因为它们都分解为单独的库

------------------ ERROR -----------------:

    --------- beginning of crash
2019-05-08 10:20:23.867 7011-7011/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.mytropolismobile, PID: 7011
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5811)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5403)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342)
        at android.app.ActivityThread.-wrap2(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.mytropolismobile-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mytropolismobile-2/lib/x86, /data/app/com.mytropolismobile-2/base.apk!/lib/x86, /system/lib, /vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
        at android.app.ActivityThread.installProvider(ActivityThread.java:5811) 
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5403) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5342) 
        at android.app.ActivityThread.-wrap2(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6077) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 

-------------- APP-LEVEL GRADLE ---------------

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        applicationId "com.mytropolismobile"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        missingDimensionStrategy 'react-native-camera', 'general'
        multiDexEnabled true
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false 
            include "armeabi-v7a", "x86", "arm64-v8a"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }

}

dependencies {
    implementation project(':react-native-fs')
    implementation project(':react-native-gesture-handler')
    implementation project(':tipsi-stripe')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-cookies')
    implementation project(':react-native-camera')
    implementation project(':react-native-maps')
    implementation project(':@react-native-community_cameraroll')
    implementation project(':react-native-firebase')
    implementation project(':react-native-pdf')


    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-wallet:16.0.1'
    implementation "com.google.android.gms:play-services-vision:17.0.2"
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

    //    implementation 'com.google.firebase:firebase-core:16.0.1'

}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
//apply plugin: 'com.google.gms.google-services'

------------------项目等级梯度----------------

buildscript {
    ext {
        buildToolsVersion = "28.0.2"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "16.0.1"
        androidMapsUtilsVersion = "0.5+"
        googlePlayServicesVisionVersion = "17.0.2"
        googlePlayServicesMapsVersion = "16.1.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.0.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenLocal()
        maven { url "https://jitpack.io" }
        maven { url "$rootDir/../node_modules/react-native/android"}
//        maven { url "https://maven.google.com" } //I Believe this is a duplicate of google() meant for older versions of Gradle
    }

}

task wrapper(type: Wrapper) {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}

0 个答案:

没有答案