> Task :app:preReleaseBuild FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:preReleaseBuild'.
> Android dependency 'com.google.android.gms:play-services-base-license:12.0.1' is set to compileOnly/provided which is not supported
下面是我的项目级别gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.2"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "11.8.0"
}
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven {
url "$rootDir/../node_modules/react-native-background-geolocation-android/android/libs"
}
maven {
url "$rootDir/../node_modules/react-native-background-fetch/android/libs"
}
jcenter()
}
}
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion "27.0.3"
}
}
}
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.7'
distributionUrl = distributionUrl.replace("bin", "all")
}
模块级gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
// apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.abc.app"
minSdkVersion rootProject.ext.minSdkVersion
multiDexEnabled true
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "3.0.0"
}
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
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// 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]
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-restart')
implementation project(':react-native-google-api-availability-bridge')
implementation project(':react-native-background-job')
implementation project(':react-native-system-setting')
implementation project(':bugsnag-react-native')
implementation project(':react-native-image-resizer')
implementation project(':react-native-onesignal')
implementation project(':react-native-image-picker')
implementation project(':react-native-sound')
implementation project(':react-native-fs')
implementation project(':react-native-signature-capture')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-background-timer')
implementation project(':react-native-background-fetch')
implementation project(':react-native-background-geolocation-android')
implementation project(':react-native-camera')
implementation project(':react-native-localization')
implementation project(':lottie-react-native')
implementation project(':react-native-geocoder')
implementation project(':react-native-vector-icons')
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
我不是来自本地背景的,所以我一直在这里打补丁,并且直到现在都可以正常工作