当前位置: 首页 > 知识库问答 >
问题:

java.lang.NoClassDefoundError:无法解析:lcom/google/android/gms/common/internal/zzbo;

曾枫
2023-03-14

我试着用android studio安装一个react-native应用程序,安装apk后应用程序就会停止。

以下是带有错误的logcat:

07-25 08:35:08.866 22185-22185/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-25 08:35:08.866 22185-22185/? E/android.os.Debug: failed to load memtrack module: -2
07-25 08:35:09.178 22201-22201/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-25 08:35:09.179 22201-22201/? E/android.os.Debug: failed to load memtrack module: -2
07-25 08:35:16.178 22266-22266/? E/memtrack: Couldn't load memtrack module (No such file or directory)
07-25 08:35:16.178 22266-22266/? E/android.os.Debug: failed to load memtrack module: -2
07-25 08:35:16.269 22278-22278/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.apply.debug, PID: 22278
    java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbo;
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
        at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
        at android.app.ActivityThread.-wrap1(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbo" on path: DexPathList[[zip file "/data/app/com.apply.debug-2/base.apk"],nativeLibraryDirectories=[/data/app/com.apply.debug-2/lib/x86, /data/app/com.apply.debug-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) 
        at android.app.ActivityThread.installProvider(ActivityThread.java:5153) 
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) 
        at android.app.ActivityThread.-wrap1(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
        Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.common.internal.zzbo
        at java.lang.Class.classForName(Native Method)
        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                ... 13 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
        bundleInStaging: true, // Overriding default configuration
        devDisabledInStaging: true,
        entryFile: "index.js"
]

project.ext.envConfigFiles = [
    debug: ".env.development",
    staging: ".env.staging",
    release: ".env.release"
]

project.ext.defaultEnvFile = ".env.development"

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "../../scripts/dotenv.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = true

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "com.apply"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 53
        versionName "1.3.3"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
        resValue "string", "build_config_package", "com.apply"
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
        multiDexEnabled true
    }

    dexOptions {
        jumboMode = true
        javaMaxHeapSize "4g"
    }

    signingConfigs {
        release {
            storeFile file(APPLY_RELEASE_STORE_FILE)
            storePassword APPLY_RELEASE_STORE_PASSWORD
            keyAlias APPLY_RELEASE_KEY_ALIAS
            keyPassword APPLY_RELEASE_KEY_PASSWORD
        }
    }

    lintOptions {
        abortOnError false
        disable "ResourceType"
    }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        debug {
            resValue "string", "app_name", "Discloz dev"
            applicationIdSuffix '.debug'
        }

        staging {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            resValue "string", "app_name", "Discloz test"
            applicationIdSuffix '.staging'
            zipAlignEnabled true
        }

        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            resValue "string", "app_name", "Discloz"
            zipAlignEnabled true
        }

    }

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    compile project(':react-native-share-extension')
    compile project(':react-native-sensitive-info')
    compile(project(':react-native-firebase')) {
        exclude group: 'com.google.firebase'
        exclude group: 'com.google.android'
        exclude group: 'com.facebook.react'
    }
    compile "com.google.firebase:firebase-core:11.0.4"

    compile "com.google.firebase:firebase-auth:11.0.4"
    compile "com.google.firebase:firebase-database:11.0.4"
    compile "com.google.firebase:firebase-messaging:11.0.4"
    compile "com.google.firebase:firebase-storage:11.0.4"
    compile "com.google.firebase:firebase-analytics:11.0.4"
    compile "com.google.android.gms:play-services-base:11.0.4"
    compile "com.android.support:multidex:1.0.3"
    compile project(':react-native-device-info')
    compile project(':react-native-code-push')
    compile project(':bugsnag-react-native')
    compile project(':react-native-branch')
    compile project(':react-native-fetch-blob')
    compile project(':react-native-vector-icons')
    compile project(':react-native-contacts')
    compile project(':react-native-video')
    compile project(':react-native-hockeyapp')
    compile project(':react-native-config')
    compile project(':react-native-camera')
    compile project(':react-native-video-editor')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:support-v4:23.0.1"
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules

}

// 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'
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'net.hockeyapp.android:HockeySDK:4.1.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven { url 'https://maven.google.com' }
        maven { url "https://jitpack.io" }
    }
}

subprojects {
    ext {
        compileSdk = 23
        buildTools = "23.0.3"
        minSdk = 16
        targetSdk = 22
    }
    afterEvaluate { project ->
        if (!project.name.equalsIgnoreCase("app")
                && project.hasProperty("android")) {
            android {
                compileSdkVersion compileSdk
                buildToolsVersion buildTools
                defaultConfig {
                    minSdkVersion minSdk
                    targetSdkVersion targetSdk
                }
                lintOptions {
                    abortOnError false
                }
            }
        }
    }
}

我尝试了很多事情:清洁,重建,...库的版本似乎在任何需要的地方都是一样的,multidex似乎是正确设置的。

你能帮帮我吗?

谢谢!

共有1个答案

王辉
2023-03-14
buildscript {
    repositories {
        jcenter()
        google()
        //or
       // maven { url 'https://maven.google.com' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'net.hockeyapp.android:HockeySDK:4.1.0'
        classpath 'com.google.gms:google-services:3.1.1' //use latest plugin version


    }
}

然后清理和重建项目。

添加最新的firebase依赖项版本

 compile "com.google.firebase:firebase-auth:16.0.1"
 compile "com.google.firebase:firebase-database:16.0.1"
 compile "com.google.firebase:firebase-messaging:16.0.1"
 compile "com.google.firebase:firebase-storage:16.0.1"
 compile "com.google.firebase:firebase-analytics:16.0.1"
 compile "com.google.android.gms:play-services-base:15.0.1"

请按此链接查看最新版本的firebase,而google play服务请按以下链接查看

 类似资料: