当前位置: 首页 > 知识库问答 >
问题:

错误:(15,55)错误:无法访问com的zza类文件。谷歌。Androidgms。常见的内部的安全包裹。未找到zza

靳金鹏
2023-03-14

这是我的build.gradle应用程序文件:

dependencies {
    //picture library
    compile 'com.github.bumptech.glide:glide:3.8.0'
    //recycler and card view
    compile 'com.android.support:support-v4:26.+'
    compile 'com.android.support:recyclerview-v7:26.+'
    compile 'com.android.support:cardview-v7:26.+'

    //json
    compile 'com.google.code.gson:gson:2.8.5'
    compile 'com.squareup.retrofit2:converter-gson:2.2.0'
    compile 'com.squareup.retrofit2:retrofit:2.4.0'
    //firebase
    compile 'com.google.firebase:firebase-core:16.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    testCompile 'junit:junit:4.12'
}

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

这是我的build.gradle项目文件

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        classpath 'com.google.gms:google-services:4.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()

        maven { url "https://maven.google.com" }
    }
}

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

我正在使用Firebase消息服务,并且我想在我的应用程序中获取通知。所以我只是检查日志中的任何更新。我的Firebase MessagingService文件是:

public void onMessageReceived(RemoteMessage remoteMessage) {

        Log.d(TAG, "onMessageReceived: "+remoteMessage.getNotification().getTitle());

        Log.d(TAG, "onMessageReceived: "+remoteMessage.getNotification().getBody());

        Log.d(TAG, "onMessageReceived: "+remoteMessage.getData());

    }

编译时,我遇到了错误。如何解决?

共有3个答案

东门仲卿
2023-03-14

添加

    compile 'com.google.firebase:firebase-core:16.0.3'
    compile 'com.google.firebase:firebase-messaging:17.3.0'
胡高寒
2023-03-14

如果您收到此错误:

error: cannot access zza class file for com.google.android.gms.common.internal.safeparcel.zza not found

然后使用这个:

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

api 'com.google.firebase:firebase-messaging:17.0.0'

它工作...

谭梓
2023-03-14

根据Firebase官方留档,请将您的依赖更新到最新版本。所以请更改以下代码行:

compile 'com.google.firebase:firebase-core:16.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'

implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.3.0'

您还可以将项目的gradle升级到最新版本:

classpath 'com.android.tools.build:gradle:3.1.4'
 类似资料: