【问题标题】:Execution failed for task ':app:processDebugGoogleServices' for react native after adding Firebase添加 Firebase 后,任务 ':app:processDebugGoogleServices' 执行本机反应失败
【发布时间】:2018-10-28 03:44:00
【问题描述】:

我添加了 React Native Firebase。我使用了 rnfirebase 模块,因为这似乎更容易。将 RNFirebase 添加到我的项目后,我开始在编译时遇到此错误

Execution failed for task ':app:processDebugGoogleServices'

这是我的 build.gradle 文件(项目)。

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.0.1'

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

allprojects {
    repositories {
        google()
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

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

这是我的 app.gradle 文件。

project.ext.react = [
    entryFile: "index.js"
]

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


def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.instantstories"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    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]
            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 "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.3"

    implementation project(':react-native-photo-view')
    implementation project(':react-native-linear-gradient')
    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
}


task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply plugin: 'com.google.gms.google-services'

我的 gradle 文件有什么问题吗?我尝试了许多 SO 答案,但似乎没有一个有效。我什至尝试在 android studio 上添加项目,但这也无济于事。除了这些,我还能做什么?

【问题讨论】:

    标签: android firebase react-native


    【解决方案1】:

    我有同样的问题。我通过删除一行应用插件来修复它:'com.google.gms.google-services'。 你可以在你的 app/build.gradle 中找到它。

    因为“com.android.application”包已经有相同的包了。

    【讨论】:

      【解决方案2】:

      如果您认为您已经将最新的 google-services.json 文件添加到您的项目中,请尝试在项目的根文件夹中运行以下命令,然后再次尝试运行您的项目。

      cd android && gradlew clean
      cd ..
      react-native run-android
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-23
        • 2020-03-22
        相关资源
        最近更新 更多