Ошибка: (15, 55) ошибка: не удается получить доступ к файлу класса zza для com.google.android.gms.common.internal.safeparcel.zza не найден - PullRequest
0 голосов
/ 05 сентября 2018

Вот мой файл приложения 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 и хочу получать уведомления в свое приложение. Поэтому я просто проверяю журнал на наличие обновлений. Мой FirebaseMessagingService файл:

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 ]

0 голосов
/ 05 сентября 2018

Согласно официальной документации 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'

Вы также можете обновить версию вашего проекта до последней версии:

classpath 'com.android.tools.build:gradle:3.1.4'
0 голосов
/ 04 февраля 2019

Если вы получаете эту ошибку:

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'

Это работает ...

0 голосов
/ 05 сентября 2018

добавить

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