错误:无法访问zzbgl。找不到com.google.android.gms.internal.zzbgl的类文件

时间:2019-06-21 05:52:50

标签: android firebase google-play-services gmsmapview gmsplace

我想在我的应用中显示地点的位置。

我收到无法访问zzbgl

的编译错误

这是我的gradle文件:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.9'
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
    implementation 'com.google.firebase:firebase-auth:17.0.0'
    implementation 'com.google.code.gson:gson:2.8.1'
    //noinspection UseOfBundledGooglePlayServices
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'de.hdodenhof:circleimageview:1.3.0'
    implementation 'com.google.maps.android:android-maps-utils:0.5'
    implementation 'com.whiteelephant:monthandyearpicker:1.3.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.tarun0.zxing-standalone:zxing-standalone:1.0.0'
    implementation 'com.edwardvanraak:MaterialBarcodeScanner:0.0.6-ALPHA'
    implementation "ru.tinkoff.scrollingpagerindicator:scrollingpagerindicator:1.0.6"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
        transitive = true;
    }
}
apply plugin: 'com.google.gms.google-services' 

显示编译错误

  

错误:无法访问zzbgl

     

未找到com.google.android.gms.internal.zzbgl的类文件

在我的活动中

@Override
    public void onLocationChanged(Location location) {

        this.location = location;

        this.googleMap.animateCamera( CameraUpdateFactory.newLatLngZoom( new LatLng( location.getLatitude(), location.getLongitude() ), 18 ) );

        this.googleMap.addMarker( new MarkerOptions().position( new LatLng( location.getLatitude(), location.getLongitude() ) ).title( "You are Hear" ) );

        Marker myMarker = googleMap.addMarker( new MarkerOptions().position( new LatLng( 0.0, 0.0 ) ) );
        myMarker.remove();

        latitude = location.getLatitude();
        longitude = location.getLongitude();

        Log.d( "latitude", String.valueOf( latitude ) );
        Log.d( "longitude", String.valueOf( longitude ) );
    }   

此行显示错误:

    this.googleMap.addMarker( new MarkerOptions().position( new LatLng( location.getLatitude(), location.getLongitude() ) ).title( "You are Hear" ) );

请帮助我。

如何解决此错误。

2 个答案:

答案 0 :(得分:1)

来自docs

  

注意:请勿使用合并的播放服务目标。它带来了数十个库,使您的应用程序膨胀。而是仅指定您的应用使用的特定Google Play服务API。

因此,删除以下依赖项:

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

并添加以下内容:

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

答案 1 :(得分:0)

升级到以下为我修复了它: implementation 'com.google.android.gms:play-services-location:18.0.0'