Java FireBase 错误:无法访问未找到 com.google.android.gms.internal.zzanb 的 zzanb 类文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41837174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 23:43:05  来源:igfitidea点击:

FireBase Error: cannot access zzanb class file for com.google.android.gms.internal.zzanb not found

javaandroidfirebase

提问by Олег Медведев

UPD. I have read these question and answer (Class file for com.google.android.gms.internal.zzaja not found). But I doesnt understand what strings i need to add or remove in my project. Because I havent this and other strings in my code: compile 'com.google.android.gms:play-services-location:9.2.0'

更新。我已阅读这些问题和答案(未找到 com.google.android.gms.internal.zzaja 的类文件)。但我不明白我需要在我的项目中添加或删除哪些字符串。因为我的代码中没有这个和其他字符串:compile 'com.google.android.gms:play-services-location:9.2.0'

I develop an android app with use of FireBase. And when I want to build my project I have an error:

我使用 FireBase 开发了一个 android 应用程序。当我想构建我的项目时,我有一个错误:

Error:(39, 25) error: cannot access zzanb class file for com.google.android.gms.internal.zzanb not found

错误:(39, 25) 错误:找不到 com.google.android.gms.internal.zzanb 的 zzanb 类文件

The error was caused by invoking statement: FirebaseAuth.getInstance().getCurrentUser();

该错误是由调用语句引起的:FirebaseAuth.getInstance().getCurrentUser();

Projects build.gradle:

项目 build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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

allprojects {
    repositories {
        jcenter()
    }
}

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

Modules build.gradle:

模块 build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "xxx.yyy.zzz"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.google.firebase:firebase-core:10.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:25.1.0'
    compile 'com.firebaseui:firebase-ui:0.6.0'
    compile 'com.android.support.test.espresso:espresso-core:2.2.2'
}

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

Please, help me to solve that error)

请帮我解决这个错误)

P.S I have already read that question (Firebase Error cannot access zzanb after using play-services-xxx:9.8.00), but i didnt understand anything, what i need to add or remove from my build.gradle files in my situation.

PS我已经阅读了那个问题(Firebase Error cannot access zzanb after using play-services-xxx:9.8.00),但我什么都不明白,在我的情况下我需要从我的 build.gradle 文件中添加或删除什么。

采纳答案by Doug Stevenson

You're mixing libraries from old and new Firebase released. Everything from Firebase that you use should be in parity. This line is reference an library from a very old Firebase release (before it became the Firebase platform at Google):

您正在混合发布的新旧 Firebase 库。您使用的 Firebase 中的所有内容都应该相同。这一行引用了一个来自非常旧的 Firebase 版本的库(在它成为 Google 的 Firebase 平台之前):

compile 'com.firebaseui:firebase-ui:0.6.0'

If you want to use the Firebase-UI library, you should use the new version of itthat matches the version of the main client library you're using. You're using 10.0.1, so according to the table on the Firebase-UI github I just linked, you want this dependency:

如果您想使用 Firebase-UI 库,您应该使用您正在使用的主客户端库版本相匹配的新版本。您使用的是 10.0.1,因此根据我刚刚链接的 Firebase-UI github 上的表格,您需要此依赖项:

compile 'com.firebaseui:firebase-ui:1.1.1'

Always make sure your Firebase-UI library matches the core Firebase SDK you're using.

始终确保您的 Firebase-UI 库与您使用的核心 Firebase SDK 相匹配。

回答by ZardozSpeaks

It looks like in your case Doug'sfix resolved your issue, but we recently encountered the same problem with a different root cause.

在您的情况下,Doug 的修复程序似乎解决了您的问题,但我们最近遇到了具有不同根本原因的相同问题。

In our case, we had configured our IDE project to use JDK8 but failed to check which version of the JDK was in use in the terminal. Because React Native runs Gradle from the command line when you type 'react-native run-android' Gradle was attempting to build using JDK10 which caused obvious issues since Android currently only supports up to JDK8. Once we configured the terminal to use JDK8 the issue was resolved.

在我们的例子中,我们已将 IDE 项目配置为使用 JDK8,但未能检查终端中使用的是哪个版本的 JDK。因为当您键入“react-native run-android”时,React Native 会从命令行运行 Gradle,所以 Gradle 尝试使用 JDK10 进行构建,这导致了明显的问题,因为 Android 目前最多只支持 JDK8。一旦我们将终端配置为使用 JDK8,问题就解决了。

TL;DR: Check what version of the JDK you are using in the terminal.

TL;DR:检查您在终端中使用的 JDK 版本。

回答by Deepak Kumar Sharma

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

dependencies {
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-analytics:17.0.1'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
/*    implementation 'com.google.firebase:firebase-core:9.2.0'                        // this line must be included to integrate with Firebase
    implementation 'com.google.firebase:firebase-messaging:10.2.1'                   // this line must be included to use FCM*/
    //implementation 'com.google.android.gms:play-services:10.2.1'
    implementation 'com.google.android.gms:play-services-maps:10.2.1'
    implementation 'com.google.firebase:firebase-core:10.2.1'
    implementation 'com.google.firebase:firebase-messaging:10.2.1'
}