【问题标题】:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbp;java.lang.NoClassDefFoundError:解析失败:Lcom/google/android/gms/common/internal/zzbp;
【发布时间】:2018-07-09 19:06:34
【问题描述】:

我正在运行一个 android react native 应用程序并成功构建完成,但是当应用程序启动时它崩溃了,我什至无法打开它。我尝试了在互联网上找到的多种解决方案,但似乎没有一个有效。 这是我的 gradle 文件:

gradle.app

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
        nodeExecutableAndArgs : ["/usr/local/bin/node"]
];

apply from: "../../node_modules/react-native/react.gradle"

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'
    defaultConfig {
        applicationId "com.tradeup"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 3
        versionName "1.7"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
}

dependencies {
    compile project(':react-native-fcm')
    compile project(':react-native-code-push')
    compile project(':react-native-image-picker')
    compile project(':react-native-splash-screen')
    compile (project(':react-native-fcm')){
        exclude group: "com.google.firebase"
    }
    compile project(':react-native-svg')
    compile project(':react-native-vector-icons')
    compile project(':react-native-linear-gradient')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  

    compile "com.google.firebase:firebase-core:11.2.0"

    compile "com.google.android.gms:play-services-base:11.2.0"

    compile "com.google.firebase:firebase-analytics:11.2.0"
    compile "com.google.firebase:firebase-auth:11.2.0"
    compile "com.google.firebase:firebase-config:11.2.0"
    compile "com.google.firebase:firebase-crash:11.2.0"
    compile "com.google.firebase:firebase-database:11.2.0"
    compile "com.google.firebase:firebase-messaging:11.2.0"
    compile "com.google.firebase:firebase-perf:11.2.0"
    compile "com.google.firebase:firebase-storage:11.2.0"
}

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

我一直在尝试修复这个问题,并且 ios 版本运行良好。谢谢。

【问题讨论】:

  • 试过 11.2.2 吗?

标签: java android react-native


【解决方案1】:

这是由于不同的库尝试使用不同的 gms 服务版本。在你的 build.gradle 文件中尝试这个 -

configurations.all {
   resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.getRequested().getGroup() == 'com.google.android.gms') {
            details.useVersion('x.x.x') // here should be your version ---> details.useVersion('15.0.1') //the latest one
        }
    }
}
dependencies {
    compile project(':react-native-fcm')
    compile project(':react-native-code-push')
    compile project(':react-native-image-picker')
    compile project(':react-native-splash-screen')
    compile (project(':react-native-fcm')){
        exclude group: "com.google.firebase"
    }
    compile project(':react-native-svg')
    compile project(':react-native-vector-icons')
    compile project(':react-native-linear-gradient')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  

    compile "com.google.firebase:firebase-core:11.2.0"

    compile "com.google.android.gms:play-services-base:11.2.0"

    compile "com.google.firebase:firebase-analytics:11.2.0"
    compile "com.google.firebase:firebase-auth:11.2.0"
    compile "com.google.firebase:firebase-config:11.2.0"
    compile "com.google.firebase:firebase-crash:11.2.0"
    compile "com.google.firebase:firebase-database:11.2.0"
    compile "com.google.firebase:firebase-messaging:11.2.0"
    compile "com.google.firebase:firebase-perf:11.2.0"
    compile "com.google.firebase:firebase-storage:11.2.0"
}

【讨论】:

  • 你能把你的整个崩溃日志放进去吗? @CarlosSerret
【解决方案2】:

我将它添加到 gradle 并解决了我的问题

implementation "com.google.android.gms:play-services-base:15.0.1"

implementation "com.google.android.gms:play-services-gcm:15.0.1"

【讨论】:

    猜你喜欢
    • 2019-06-25
    • 2018-09-24
    • 1970-01-01
    • 2017-05-10
    • 2015-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多