Error: cannot access zzbgl

这一生的挚爱 提交于 2019-12-17 21:06:02

问题


I am developing an application and I am getting the following error:

error: cannot access zzbgl
class file for com.google.android.gms.internal.zzbgl not found

I know there's a question here in StackOverflow with the same error that I'm getting posted 4 days ago but the answer did not help in my case. (I am talking about this one)

The error appeared just right after setting Firebase Analytics in my project.

My build.gradle (Module: app) file is this:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 26
    buildToolsVersion '27.0.3'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId 'com.geoactio.montferri'
        minSdkVersion 14
        targetSdkVersion 26
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    dependencies {
         implementation 'com.android.support:multidex:1.0.3'
         implementation 'com.android.support:appcompat-v7:26.1.0'
//        compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0'
        implementation 'com.google.android.gms:play-services:12.0.1'
        //implementation 'com.google.android.gms:play-services-maps:15.0.1'
        //implementation 'com.google.android.gms:play-services-location:15.0.1'
        implementation "com.google.android.gms:play-services-base:15.0.1"
        implementation 'com.navercorp.pulltorefresh:library:3.2.3@aar'

    }
    productFlavors {
    }
    lintOptions {
        disable 'MissingTranslation'
    }

    dexOptions {
        javaMaxHeapSize "4g"
        preDexLibraries = false
    }
}
repositories {
    maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'

    implementation('com.crashlytics.sdk.android:crashlytics:2.9.4@aar') {
    transitive = true;
    }
}

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

My build.gradle (Project: myPorojectName) file is this:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.1.0'
    }
}

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

And clicking in the error leads me here, just after new MarkerOptions():

mapView.addMarker(new MarkerOptions().position(new LatLng(puntomarker.getLatitud(), puntomarker.getLongitud()))
                    .zIndex(0.5f)
                    .anchor(0.5f, 0.5f)
                    .title(puntomarker.getId() + "")
                    .snippet(puntomarker.getNombre())
                    .icon(BitmapDescriptorFactory.fromBitmap(((BitmapDrawable) marker).getBitmap())));

(being mapView a GoogleMap instance).

I hope someone can see the error and solve this, thank you so much in advance. If you need any more information in order to solve this, please let me know.


回答1:


The Google API Release Notes indicate that support for the combined play-services library ended in April 2018:

Starting with 15.0.0, there will no longer be a play-services alias target to pull in all Google Play services components. This has been recommended against for some time.

You can no longer specify a single dependency on the combined Google Play services target like this anymore:

implementation 'com.google.android.gms:play-services:12.0.1'.

When this was supported with previous versions, it pulled in ALL the Google Play libs way more than you need. See the list of APIs in Table 1 of the Setup Guide and include only the specific ones your app uses.

A check of the Google Maven Repository confirms that version 12.0.1 was the last version of the combined play-services target.

So please delete the above implementation and use only:

implementation "com.google.android.gms:play-services-base:15.0.1"

If you are also using other play services, please add them as separate dependencies.




回答2:


I think your main reason for the error is that you are using 2 different versions for play services libraries

        implementation 'com.google.android.gms:play-services:12.0.1'

Here it is 12.0.1

        implementation "com.google.android.gms:play-services-base:15.0.1"

While here it is 15.0.1.

Try to use same version of related libraries everywhere.




回答3:


Just simply you need to change a Dependency because 12.0.1 is no more

implementation 'com.google.android.gms:play-services:12.0.1'

To

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

And press sync Gradle

Hope this may help you




回答4:


updates the version of all dependencies. Generally, this error will happen if you are working with several new and old dependencies.



来源:https://stackoverflow.com/questions/51841006/error-cannot-access-zzbgl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!