我一直在出错:
任务':app:processDebugGoogleServices'的执行失败。 >无法删除:D:\ Program \ ReactNative \ MobileSC_New \ android \ app \ build \ Generated \ res \ google-services \ debug 这是我的应用级别gradle文件
apply plugin: "com.android.application"
apply plugin: "io.fabric"
// Need to set this when we have variant setup
//project.ext.envConfigFiles = [
// debug: ".env.dev",
// release: ".env",
// staging: ".env",
//]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.mobilesc"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode project.env.get("APP_VERSION_CODE").toInteger()
versionName project.env.get("APP_VERSION_NUMBER")
multiDexEnabled true
// manifestPlaceholders = [
// FABRIC_API_KEY:project.env.get("FABRIC_API_KEY"),
// GOOGLE_MAPS_ANDROID_API_KEY:project.env.get("GOOGLE_MAPS_ANDROID_API_KEY")
// ]
resValue "string", "build_config_package", "com.mobilesc"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
manifestPlaceholders = [enableCrashReporting:"false"]
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
manifestPlaceholders = [enableCrashReporting:"true"]
}
}
// 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:
// https://developer.android.com/studio/build/configure-apk-splits.html
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
}
}
}
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'me.leolin:ShortcutBadger:1.1.21@aar' // <-- Add this line if you wish to use badge on Android
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9@aar') {
transitive = true
}
}
apply plugin: 'com.google.gms.google-services'
// CRASH ISSUE: https://github.com/invertase/react-native-firebase/issues/2411
// WORKAROUND for com.google.gms:google-services:4.2.0: https://github.com/invertase/react-native-firebase/issues/1676#issuecomment-441243419
//googleServices.disableVersionCheck = true
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
这是我的项目级别gradle文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.28.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
// maven {
// url 'https://maven.google.com/'
// name 'Google'
// }
maven { url 'https://jitpack.io' }
}
// subprojects {
// afterEvaluate {project ->
// if (project.hasProperty("android")) {
// android {
// compileSdkVersion rootProject.ext.compileSdkVersion
// buildToolsVersion rootProject.ext.buildToolsVersion
// }
// }
// }
// }
}
我尝试遵循此主题,但是没有一个起作用 Gradle Error:Execution failed for task ':app:processDebugGoogleServices'
答案 0 :(得分:0)
只需删除android / app /中的build文件夹,然后以管理员身份运行您的cmd。
答案 1 :(得分:0)
有点晚了,但它可能对某些人有所帮助-确保您不要忘记将google-services.json
添加到项目文件夹中。