java.lang.NoClassDefFoundError:无法解决以下问题:Lcom / google / android / gms / common / util / zzt;

时间:2019-02-26 11:44:23

标签: java android

请帮助我解决此错误。

每当第一次在设备中安装我的应用程序时,它就会崩溃。重新打开应用程序后,它可以正常工作。

  java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzt;
    at com.google.android.gms.gcm.GcmTaskService.onBind(Unknown Source:2)
    at android.app.ActivityThread.handleBindService(ActivityThread.java:3559)
    at android.app.ActivityThread.access$1400(ActivityThread.java:199)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1671)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.util.zzt" on path: DexPathList[[zip file "/data/app/realm.com.realm-d6u0u9PECofXK-J8QnDdVw==/base.apk"],nativeLibraryDirectories=[/data/app/realm.com.realm-d6u0u9PECofXK-J8QnDdVw==/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.google.android.gms.gcm.GcmTaskService.onBind(Unknown Source:2) 
    at android.app.ActivityThread.handleBindService(ActivityThread.java:3559) 
    at android.app.ActivityThread.access$1400(ActivityThread.java:199) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1671) 
    at android.os.Handler.dispatchMessage(Handler.java:106) 
    at android.os.Looper.loop(Looper.java:193) 
    at android.app.ActivityThread.main(ActivityThread.java:6669) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)  

应用程序级别build.gradle

    apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'org.jetbrains.kotlin.android.extensions'

apply plugin: 'io.fabric'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "My application package ID"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 2
        versionName "1.0"
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    //Google Place API
    implementation 'com.google.android.gms:play-services-places:16.0.0'

    //Google Location API
    implementation 'com.google.android.gms:play-services-location:16.0.0'

    //Firebase
    implementation 'com.google.firebase:firebase-messaging:17.4.0'

    //QuickBlox
    implementation "com.quickblox:quickblox-android-sdk-messages:3.3.1"
    implementation "com.quickblox:quickblox-android-sdk-chat:3.3.1"
    implementation "com.quickblox:quickblox-android-sdk-content:3.3.1"

    //Multidex
    implementation'com.android.support:multidex:1.0.3'
}

apply plugin: 'com.google.gms.google-services'

项目级app.gradle

buildscript {
    ext.kotlin_version = '1.3.21'
    repositories {
        google()
        jcenter()

        //  Crashlytics
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        //Crashlytics
        classpath 'io.fabric.tools:gradle:1.27.1'

    }
}

allprojects {
    repositories {
        google()
        jcenter()

        maven {
            url 'https://maven.google.com/'
        }
        maven {
            url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/"

        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我无法解决此错误。请让我知道代码中有什么问题。 提前谢谢

1 个答案:

答案 0 :(得分:3)

当我尝试通过更新所有播放服务和Firebase Gradle依赖项来解决此错误的方法时,添加了Multidex文件,但是仍然遇到相同的问题,但是在app.gradle中添加了以下内容。问题已解决。

implementation 'com.google.android.gms:play-services-gcm:16.1.0'