我想在我的插件gradle文件中设置我的Google Play服务版本11.8.0
我的主要应用gradle
buildscript {
repositories {
mavenLocal()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
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" }
}
google()
}
}
ext {
gps_version = '11.8.0'
}
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
}
}
if (project.hasProperty("com.google.android.gms")) {
compile "com.google.android.gms:play-services-gcm:$gps_version"
}
}
}
我的第三方插件gradle如下
apply plugin: 'com.android.library'
def DEFAULT_COMPILE_SDK_VERSION = 23
def DEFAULT_BUILD_TOOLS_VERSION = "25.0.2"
def DEFAULT_TARGET_SDK_VERSION = 22
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "+"
android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
buildToolsVersion project.hasProperty('buildToolsVersion') ? project.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 16
targetSdkVersion project.hasProperty('targetSdkVersion') ? project.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
versionCode 2
versionName "1.1"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
lintOptions {
warning 'InvalidPackage'
}
}
dependencies {
def googlePlayServicesVersion =
project.hasProperty('googlePlayServicesVersion') ?
project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
compile 'com.facebook.react:react-native:+'
compile "com.google.android.gms:play-services-gcm:$googlePlayServicesVersion"
}
运行代码时,我无法从我的应用程序级别gradle变量中的插件gradle文件中设置Google Play服务版本,我该如何解决呢?您的所有建议都是