1
我有一个android studio项目,我试图将gradle从稳定版本2.0.0移植到实验版本0.7.0-beta1:错误移植gradle:2.0.0到gradle-experimental:0.7.0-beta1?
这是我的android标签模块中的工作代码my 2.0 0.0 gradle这个代码:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.test.myapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "myNativeLib"
}
}
sourceSets.main {
jniLibs.srcDir 'src/main/libs' //set .so files location to libs
jni.srcDirs = [] //disable automatic ndk-build call
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
task runSwig(type: Exec, description: 'Run swig config') {
workingDir 'src/main'
commandLine 'cmd', '/c', 'swig.bat'
}
Properties props = new Properties()
props.load(new FileInputStream(file(project.property("KeyStore.properties"))))
signingConfigs {
storeSignature {
storeFile = file(props['KEYSTORE'])
storePassword = props['KEYSTORE_PASSWD']
keyAlias = props['KEYSTORE_MYAPP']
keyPassword = props['KEYSTORE_MYAPP_PASSWD']
}
}
buildTypes {
def SERVER_URL = "SERVER_URL"
debug {
debuggable true
jniDebuggable true
buildConfigField "String", SERVER_URL, "\"http://testusound.eastus.cloudapp.azure.com/androidbackend/checkjson\""
versionNameSuffix getMasterName() + "." + getDate()
}
release {
signingConfig signingConfigs.storeSignature
debuggable false
jniDebuggable false
minifyEnabled false
buildConfigField "String", SERVER_URL, "\"http://www.usound.co/androidbackend/checkjson\""
versionNameSuffix getMasterName()
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
现在,这里是我试图重写我的代码为expermiental撑着0.7.0-β1:
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig.with {
applicationId "com.test.myapp"
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 23
versionCode 1
versionName "1.0"
}
ndk {
moduleName "myNativeLib"
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
task runSwig(type: Exec, description: 'Run swig config') {
workingDir 'src/main'
commandLine 'cmd', '/c', 'swig.bat'
}
buildConfigFields.with {
create() {
type "String"
name "SERVER_URL"
value "\"http://www.myserver.com/backend/checkjson\""
}
}
buildConfigFields.with {
create() {
type "String"
name "TEST_SERVER_URL"
value "\"http://www.mytestserver.com/backend/checkjson\""
}
}
sources {
main {
jni {
source {
srcDir "src"
}
}
jni.srcDirs = [] //disable automatic ndk-build call
}
}
buildTypes {
debug {
debuggable true
jniDebuggable true
buildConfigField $("android.buildConfigFields.TEST_SERVER_URL")
versionNameSuffix getMasterName() + "." + getDate()
}
release {
signingConfig = $("android.signingConfigs.mySignature")
debuggable false
jniDebuggable false
minifyEnabled false
buildConfigField $("android.buildConfigFields.SERVER_URL")
versionNameSuffix getMasterName()
proguardFiles.add(file('proguard-rules.pro'))
}
}
Properties props = new Properties()
props.load(new FileInputStream(file(project.property("KeyStore.properties"))))
}
android.signingConfigs {
create("mySignature")
storeFile = file(props['KEYSTORE'])
storePassword = props['KEYSTORE_PASSWD']
keyAlias = props['KEYSTORE_MYAPP']
keyPassword = props['KEYSTORE_MYAPP_PASSWD']
}
}
我得到这个错误错误与signingConfigs:
Error:Attempt to read a write only view of model of type 'java.lang.Object' given to rule 'android.signingConfigs { ... } @ app\build.gradle line 165, column 5'
在我的代码是这一行:
android.signingConfigs {
了,我可以使用位于我的主文件夹一个文件名为keystore.properties我签字CONFIGS(我想保持这种方式一个单独的文件,所以我没有上传我的keystore签名数据到git,所以我没有把签名配置键,就像在当前的实验gradle项目中)。
我在这里错过了什么?我应该如何编写签名配置以使用从文件加载的属性?因为我刚刚进入实验gradle,请随意给我一些您认为可能有用的示例或信息。