NoSuchFieldError:PREFER_HIGHEST_OR_REMOTE_VERSION_NO_FORCE_STAGING

时间:2018-11-22 11:38:15

标签: android firebase

使用Firebase产品时遇到java.lang.NoSuchFieldError错误。

应用程序随机崩溃,每几次启动一次,我看不到任何明显的原因。

Crashlytics识别为两个独立的问题:

第一:

Fatal Exception: java.lang.NoSuchFieldError
No field PREFER_HIGHEST_OR_REMOTE_VERSION_NO_FORCE_STAGING of type Lcom/google/android/gms/dynamite/DynamiteModule$VersionPolicy; in class Lcom/google/android/gms/dynamite/DynamiteModule; or its superclasses (declaration of 'com.google.android.gms.dynamite.DynamiteModule' appears in /data/app/com.myjob.exchange-1/base.apk:classes2.dex)
com.google.android.gms.flags.FlagValueProvider.initialize (Unknown Source)
com.google.android.gms.flags.FlagRegistry.initialize (Unknown Source)
android.os.HandlerThread.run (HandlerThread.java:61)

第二:

Fatal Exception: java.lang.NoSuchFieldError
No static field PREFER_HIGHEST_OR_REMOTE_VERSION_NO_FORCE_STAGING of type Lcom/google/android/gms/dynamite/DynamiteModule$VersionPolicy; in class Lcom/google/android/gms/dynamite/DynamiteModule; or its superclasses (declaration of 'com.google.android.gms.dynamite.DynamiteModule' appears in /data/app/com.myjob.exchange-rCklgf0d6JLM3ymH4dG31Q==/base.apk:classes3.dex)
com.google.android.gms.flags.FlagValueProvider.initialize (Unknown Source:7)
com.google.android.gms.flags.FlagRegistry.initialize (Unknown Source:4)
android.os.HandlerThread.run (HandlerThread.java:65)

我想知道可能是什么原因,至少是什么库。

任何帮助表示赞赏。

我的build.gradle文件(项目级别)

buildscript {
    ext.kotlin_version = '1.2.71'
    ext.anko_version='0.10.6'
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.26.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
        }
    }
}

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

我的build.gradle-应用程序文件。

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.myjob.exchange"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 10
        versionName "1.1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.android.support:multidex:1.0.3'

    // Anko
    implementation "org.jetbrains.anko:anko:$anko_version"

    // Firebase
    implementation 'com.google.firebase:firebase-core:16.0.5'
    implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
    implementation 'com.google.firebase:firebase-firestore:17.1.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.38.1'

    implementation 'com.google.firebase:firebase-messaging:17.3.4'

    //Google Play
    implementation 'com.google.android.gms:play-services-places:16.0.0'

    //Crashlytics
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'

    // Image slider
    implementation "com.android.support:support-v4:+"
    implementation 'com.squareup.picasso:picasso:2.5.0'
    implementation 'com.nineoldandroids:library:2.4.0'
    implementation 'com.daimajia.slider:library:1.1.5@aar'

    // Retrofit library
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.4.0'

}

apply plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '28.0.0'
            }
        }

    }
}

1 个答案:

答案 0 :(得分:1)

在此帖子中找到了答案:https://blog.jakelee.co.uk/tokenrefresher-fatal-crash-when-using-firebaseui/

简短交谈-这解决了该问题: 将com.firebaseui:firebase-ui-auth依赖性从4.1.0更新到4.2.1