【问题标题】:java.lang.NoSuchMethodError: No static method zzb(ZLjava/lang/Object;)V in class Lcom/google/android/gms/common/internal/zzaa; or its super classesjava.lang.NoSuchMethodError:Lcom/google/android/gms/common/internal/zzaa 类中没有静态方法 zzb(ZLjava/lang/Object;)V;或其超类
【发布时间】:2017-11-18 10:41:50
【问题描述】:

我查看了 Firebase 文档,然后搜索了所有 github 问题以及所有堆栈溢出帖子,但我仍然一次又一次地收到此错误。我已经卡了几个小时了,请看一下。它说-

java.lang.NoSuchMethodError: No static method zzb(ZLjava/lang/Object;)V in class Lcom/google/android/gms/common/internal/zzaa; or its super classes (declaration of 'com.google.android.gms.common.internal.zzaa' appears in /data/app/com.masquerade.priyanshu.topcoder-2/split_lib_dependencies_apk.apk)

根据其他堆栈溢出帖子,当我尝试更改 firebase 核心和数据库版本时,我又收到一堆错误,说版本不兼容。

这是 build.gradle( 模块:app)

apply plugin: 'com.android.application'
repositories {
    mavenLocal()
    flatDir {
        dirs 'libs'
    }
}

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.masquerade.priyanshu.topcoder"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
//    implementation 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:appcompat-v7:26.1.0'
    compile 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//

    compile 'com.google.firebase:firebase-core:11.6.0'
    compile 'com.android.support:design:26.1.0'
    compile 'com.google.firebase:firebase-database:11.6.0'
 compile 'com.firebaseui:firebase-ui-storage:1.0.0'
    // Displaying images
    compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:cardview-v7:21.+'
}
apply plugin: 'com.google.gms.google-services'

这是 build.gradle(Project:app) -

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenLocal()
        maven {
            url 'https://maven.fabric.io/public'
        }

    }
}

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

编辑 - 我也在compile 'com.google.firebase:firebase-core:11.6.0' 上收到此警告

警告是 -

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 11.6.0, 11.4.2. Examples include com.google.android.gms:play-services-basement:11.6.0 and com.google.firebase:firebase-storage:11.4.

【问题讨论】:

    标签: java android firebase android-gradle-plugin


    【解决方案1】:

    要解决这个问题,请从您的 build.gradle(Project:app) 文件中更改以下代码行:

    url 'https://maven.fabric.io/public'
    

    url "https://maven.google.com" // Google's Maven repository
    

    也改变这行代码:

    compile 'com.firebaseui:firebase-ui-storage:1.0.0'
    

    compile 'com.firebaseui:firebase-ui-storage:3.1.0'
    

    也改变这行代码:

    compile 'com.google.firebase:firebase-core:11.6.0'
    compile 'com.google.firebase:firebase-database:11.6.0'
    

    compile 'com.google.firebase:firebase-core:11.4.2'
    compile 'com.google.firebase:firebase-database:11.4.2'
    

    因为Firebase/Play Services Version 11.4.2FirebaseUI Version 3.1.0 一起使用,如here 所示。

    还在默认配置中将multiDexEnabled 设置为true。

    【讨论】:

    • 更新 firebase-ui-storage 时出现此运行时错误 - java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbp;
    • 将 11.4.2 更改为 11.6.0 @Somebody
    • @Peter_Haddad 什么都不是 11.4.2,我到处都用过 11.6.0
    • @PeterHaddad 谢谢,但有人应该改变相反的,从 11.60 到 11.4.2。
    • @Alex 当我将 11.6.0 更改为 11.4.2 时,我收到此错误 - 错误:任务“:app:transformDexArchiveWithExternalLibsDexMergerForDebug”的执行失败。 > com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex
    猜你喜欢
    • 2021-02-11
    • 1970-01-01
    • 2017-11-03
    • 1970-01-01
    • 2021-10-17
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多