11

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.

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
P. Vera
  • 315
  • 4
  • 11

4 Answers4

16

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.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
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.

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
  • I was getting another error if I upgraded the version, but as they told me, I changed it and I used only the libraries I need, not the whole google services. Thank you! – P. Vera Aug 14 '18 at 12:15
  • It was me who suggested you that too – Vivek Mishra Aug 14 '18 at 12:16
  • sorry, I didn't notice before posting the comment – P. Vera Aug 14 '18 at 12:17
  • The reason the OP is getting that error isn't because he is using "2 different versions" but because this `implementation 'com.google.android.gms:play-services:12.0.1'` doesn't exist anymore. – Alex Mamo Aug 14 '18 at 12:23
  • @AlexMamo probably you are wrong with this, I just tried that I was able to successfully sync my project.It just gives a warning to avoid using the bundle – Vivek Mishra Aug 14 '18 at 12:32
  • @VivekMishra There aren't "2 different versions" at all. Now, there are different dependencies for different services. A line of code like this: `implementation 'com.google.android.gms:play-services:12.0.1'` is doesn't mean that is a different version, that line of code does not exist anymore. That's why it cannot be used. Please see my answer above. – Alex Mamo Aug 14 '18 at 12:56
  • @AlexMamo that's what I am saying, although we should not use the whole play services bundle, but what you are saying that the whole play services doesn't exist anymore is wrong. I tried and was able to include complete play services dependency in my project. So I just want to point out this that it still exists. – Vivek Mishra Aug 15 '18 at 07:44
  • And were able to use the different services too? I'm affraid you were not. – Alex Mamo Aug 15 '18 at 07:48
  • In that case no as it will be duplicate. But when you have all you don't need to define individual components. – Vivek Mishra Aug 15 '18 at 07:52
0

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

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
  • This is the same solution @VivekMishra posted just down below, and as I said I got an error when I did this. The right solution is written in a comment to the original post (also by the same user). Thank you anyway for your help – P. Vera Aug 16 '18 at 06:20
0

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

Bacar Pereira
  • 1,025
  • 13
  • 18