java.lang.NoSuchMethodError:类Lcom / google / android / gms / common / zzc中没有静态方法zza(Landroid / content / Context;)V;它的超一流

时间:2019-02-25 15:00:30

标签: java android firebase gradle

我正在尝试在我的Android项目中使用firebase-core库,但它在我发布的apk中一直给我这个NoSuchMethodError。但是,它在模拟器中可以正常工作。异常消息是这样的:

java.lang.NoSuchMethodError: No static method zza(Landroid/content/Context;)V in class Lcom/google/android/gms/common/zzc; or its super classes (declaration of 'com.google.android.gms.common.zzc' appears in /data/app/com.xxxx.xxxx/base.apk): com.google.android.gms.measurement.internal.zzfx.zzs(Unknown Source)

我使用Android Studio的firebase助手添加了firebase-core:16.0.7。我的gradle文件如下:

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url "https://maven.google.com"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
}

/**
 * This line applies the com.android.application plugin. Note that you should
 * only apply the com.android.application plugin. Applying the Java plugin as
 * well will result in a build error.
 */
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

/**
 * This dependencies block includes any dependencies for the project itself. The
 * following line includes all the JAR files in the libs directory.
 */
dependencies {
    compile 'com.google.firebase:firebase-core:16.0.7'
    compile project(':Shared')
    compile 'com.google.guava:guava:16.0.1'
    compile 'joda-time:joda-time:2.10.1'
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile files('libs/js.jar')
    compile files('libs/gps-stripped.jar')
    compile files('libs/antlr-runtime-3.2.jar')
    compile files('libs/jackson-all-1.9.11.jar')
    compile files('libs/logback-android-1.1.1-6.jar')
    compile files('libs/slf4j-api-1.7.21.jar')
    compile 'com.github.jsqlparser:jsqlparser:0.9.6'
    compile files('libs/Android-Languages.jar')
    androidTestCompile 'junit:junit:4.12'
}

/**
 * The android{} block configures all of the parameters for the Android build.
 * You must provide values for at least the build tools version and the
 * compilation target.
 */
android {
    compileSdkVersion 28
    buildToolsVersion "26.0.3"
    buildTypes {
        release {
            minifyEnabled false
            lintOptions {
                disable 'MissingTranslation'
                abortOnError false
            }
        }
        debug {
            minifyEnabled false
            lintOptions {
                disable 'MissingTranslation'
                abortOnError false
            }
        }
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        //instrumentTest.setRoot('tests')

        /**
         * Move the build types to build-types/<type>
         * For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
         * This moves them out of them default location under src/<type>/... which would
         * conflict with src/ being used by the main source set.
         * Adding new build types or product flavors should be accompanied
         * by a similar customization.
         */
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    packagingOptions {
        pickFirst 'META-INF/license.txt'
        pickFirst 'META-INF/LICENSE'
    }
    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 28
        multiDexEnabled true
    }
    productFlavors {
    }
}

有关如何解决此问题的任何线索?谢谢。

0 个答案:

没有答案