首页 > 解决方案 > 我该如何解决'在android中不断停止'错误?

问题描述

我正在努力解决在 android 模拟器上显示“不断停止”错误的错误。我搜索了错误的来源,发现每当我在应用程序级别构建 gradle 添加应用插件:'com.google.gms.google-services' 这一行时,我的应用程序都会停止。但是如果我不添加那条线,我就不能再使用 firebase 了。我该如何解决这个问题?你能帮帮我吗?先感谢您。

def enableSeparateBuildPerCPUArchitecture = false


def enableProguardInReleaseBuilds = false

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.instagram_clone"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}
}

dependencies {
implementation project(':react-native-firebase')
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+"  // From node_modules
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.8"
implementation "com.google.firebase:firebase-auth:16.2.1"
implementation "com.google.firebase:firebase-firestore:18.2.0"
implementation "com.google.firebase:firebase-storage:17.0.0"
implementation project(':react-native-image-picker')


} 


task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply plugin: 'com.google.gms.google-services' //this line creates error

标签: javascriptandroidfirebasereact-native

解决方案


当你创建一个模拟器时,有一些支持谷歌,一些不支持。确保创建与 Google Play 服务兼容的模拟器。

此列显示 Google Play 兼容性


推荐阅读