原因:java.lang.ClassNotFoundException:找不到类“ com.google.android.gms.common.internal.zzbq”

时间:2018-10-27 16:42:31

标签: java android gradle apk

这是我的项目gradle

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:4.1.0'

    }
}

allprojects {
    repositories {
        jcenter()

        maven {
            url 'https://maven.google.com/'
        }
        google()
    }
}

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

这是我的应用gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId 'com.ramin.quiz'
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.firebase:firebase-database:11.8.0'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    //noinspection UseOfBundledGooglePlayServices
//    implementation 'com.google.android.gms:play-services-analytics:16.0.4'
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.mcxiaoke.volley:library:1.0.18'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation 'com.github.bluejamesbond:textjustify-android:2.1.1'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.easing:library:1.0.1@aar'
    implementation 'com.daimajia.androidanimations:library:1.1.3@aar'
    //compile 'com.google.android.gms:play-services-appstate:7.3.0'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-core:16.0.4'
    implementation 'com.facebook.android:facebook-android-sdk:4.38.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'com.google.android.gms:play-services-ads:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:16.0.1'

    androidTestImplementation 'com.android.support:multidex-instrumentation:1.0.3'
}
apply plugin: 'com.google.gms.google-services'

此行在MainApplication.class上获取错误

GoogleAnalytics analytics = GoogleAnalytics.getInstance(MainApplication.this);

此行在menuHomeScreenActivity.class上显示错误

Tracker mTracker = application.getDefaultTracker();

我的logcat:

10-27 19:55:14.008 17432-17432/com.ramin.quiz E/UncaughtException: java.lang.NoClassDefFoundError: Failed resolution of:
     

Lcom / google / android / gms / common / internal / zzbq;               com.google.android.gms.internal.zzark.zzbl(未知来源:0)               位于com.google.android.gms.analytics.GoogleAnalytics.getInstance(未知   来源:0)               在com.ramin.quiz.application.MainApplication.getDefaultTracker( MainApplication.java:40 )               在com.ramin.quiz.activity.MenuHomeScreenActivity.onCreate( MenuHomeScreenActivity.java:153 )               在android.app.Activity.performCreate(Activity.java:7009)               在android.app.Activity.performCreate(Activity.java:7000)               在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)               在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)               在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)               在android.app.ActivityThread.-wrap11(未知来源:0)               在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1589)               在android.os.Handler.dispatchMessage(Handler.java:106)               在android.os.Looper.loop(Looper.java:164)               在android.app.ActivityThread.main(ActivityThread.java:6494)               在java.lang.reflect.Method.invoke(本机方法)               在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:438)               在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)            原因:java.lang.ClassNotFoundException:在路径上找不到类“ com.google.android.gms.common.internal.zzbq”。   DexPathList [[zip文件   压缩文件“ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/base.apk”   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_dependencies_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_resources_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_0_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_1_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_2_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_3_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_4_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_5_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_6_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_7_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_8_apk.apk”,   压缩文件   “ /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ==/lib   / system / lib,/ vendor / lib]]               在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)               在java.lang.ClassLoader.loadClass(ClassLoader.java:379)               在java.lang.ClassLoader.loadClass(ClassLoader.java:312)               com.google.android.gms.internal.zzark.zzbl(未知来源:0)               位于com.google.android.gms.analytics.GoogleAnalytics.getInstance(未知   来源:0)               在com.ramin.quiz.application.MainApplication.getDefaultTracker( MainApplication.java:40 )               在com.ramin.quiz.activity.MenuHomeScreenActivity.onCreate( MenuHomeScreenActivity.java:153 )               在android.app.Activity.performCreate(Activity.java:7009)               在android.app.Activity.performCreate(Activity.java:7000)               在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)               在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)               在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)               在android.app.ActivityThread.-wrap11(未知来源:0)               在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1589)               在android.os.Handler.dispatchMessage(Handler.java:106)               在android.os.Looper.loop(Looper.java:164)               在android.app.ActivityThread.main(ActivityThread.java:6494)               在java.lang.reflect.Method.invoke(本机方法)               在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:438)               在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)             禁止:java.io.IOException:找不到用于dex位置的原始dex文件   /data/app/com.ramin.quiz-RNjLhiGfgiVubfbHvVcKDQ == / split_lib_resources_apk.apk

1 个答案:

答案 0 :(得分:0)

我并不总是工作,但是请尝试此https://developer.android.com/studio/build/multidex。 它适用于因大小而出错的应用程序。

您要将其添加到您的依赖项中:

dependencies { implementation 'com.android.support:multidex:1.0.3' }

有关更多说明,请阅读链接的文章。