简体   繁体   中英

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq; when adding Google Maps to Android app

I am adding a Google Maps Activity to my app which is connected to a Parse server. I've simply added the maps activity and created the relevant API key and in an attempt to run the app I get the following:

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.parse.starter, PID: 14204
              java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
                  at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2)
                  at android.app.ActivityThread.installProvider(ActivityThread.java:6285)
                  at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851)
                  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772)
                  at android.app.ActivityThread.-wrap1(Unknown Source:0)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
                  at android.os.Handler.dispatchMessage(Handler.java:105)
                  at android.os.Looper.loop(Looper.java:164)
                  at android.app.ActivityThread.main(ActivityThread.java:6541)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
               Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList[[zip file "/data/app/com.parse.starter-pGR71qLVNb0LE-PnOSAJaA==/base.apk"],nativeLibraryDirectories=[/data/app/com.parse.starter-pGR71qLVNb0LE-PnOSAJaA==/lib/x86, /system/lib, /vendor/lib]]
                  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                  at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source:2) 
                  at android.app.ActivityThread.installProvider(ActivityThread.java:6285) 
                  at android.app.ActivityThread.installContentProviders(ActivityThread.java:5851) 
                  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5772) 
                  at android.app.ActivityThread.-wrap1(Unknown Source:0) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661) 
                  at android.os.Handler.dispatchMessage(Handler.java:105) 
                  at android.os.Looper.loop(Looper.java:164) 
                  at android.app.ActivityThread.main(ActivityThread.java:6541) 
                  at java.lang.reflect.Method.invoke(Native Method) 
                  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

I believe the error is within the gradle scripts as they are highlighted red. Thus, they are as follows:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
    }
}

allprojects {
    repositories {
        mavenCentral()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

ext {
    compileSdkVersion = 22
    buildToolsVersion = "23.0.1"

    minSdkVersion = 14
    targetSdkVersion = 23
}

The other gradle file is:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.parse.starter"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.parse.bolts:bolts-tasks:1.3.0'
    compile 'com.parse:parse-android:1.13.0'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.android.support:multidex:1.0.0'
}

I have tried updating the dependency version as I am getting the red error line under

compile 'com.android.support:appcompat-v7:23.4.0'

As well as the other dependencies however the error still remains. I am very new to Android development so I have little idea to what's going on in these files.

EDIT: As soon as I comment out:

implementation 'com.google.android.gms:play-services-maps:15.0.1'

The program runs without error, but obviously, google maps is not working. Are the dependency versions incompatible with the gradle version?

You have different versions of

com.google.android.gms:play-services:9.4.0
com.google.android.gms:play-services-maps:15.0.1

Fix it and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM