我已经成功地修改了我的build.gradle以使用gradle-实验性的,但是当尝试添加一个signingConfigs块时,它失败了。我尽我所能地遵循了http://tools.android.com/tech-docs/new-build-system/gradle-experimental的指示,但我总是得到以下错误:
配置项目':app‘时出现问题。 以下模型规则未绑定: model.android.signingConfigs >命名(发布)可变:- android.signingConfigs.release android.signingConfigs.release
我搜索错误,但找不到任何相关的东西。“下列示范规则未受约束”是什么意思?
下面是我的signingConfig块的样子,它在android块之外,修改为使用= as,这是使用gradle-实验性的情况。
android.signingConfigs {
release {
storeFile = file("myreleasekey.keystore")
storePassword = "password"
keyAlias = "MyReleaseKey"
keyPassword = "password"
}
}
发布于 2015-11-27 01:27:34
虽然,对于问这个问题的用户来说已经晚了,但它可能会对其他人有所帮助。
下面的代码示例对我来说很好。我用以下设置测试了它-- Gradle -实验性-0.4.0,Gradle包装器- 2.8,AndroidStudio2.0预览版。
apply plugin: 'com.android.model.application'
model {
def signConf // <-- Note the changes made here
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.0"
defaultConfig.with {
applicationId = "in.atultiwari.helloandroidjni"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file("proguard-rules.pro"))
signingConfig = signConf // <-- Note the changes made here
}
}
android.signingConfigs { // <-- Note the changes made here
create("signRelease") { // <-- Note the changes made here
keyAlias = 'myKeyAlias'
keyPassword = 'myKeyPassword'
storeFile = file('myKestoreFile.jks')
storePassword = 'myKeystorePassword'
signConf = it
}
}
android.ndk {
moduleName = "hello-android-jni"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
P.S. -是而不是与minifyEnabled = true
一起工作,在这种情况下会发生与transformClassesAndResourcesWithProguardForRelease
相关的错误。
编辑- 1. minifyEnabled = true
正在使用上述设置。原来我的保护规则文件是空的,不知何故它导致了上面提到的错误。
发布于 2016-07-09 15:46:19
下面是如何添加gradle试验性0.7的签名:
应用插件:"com.android.model.application“
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildTypes {
release {
signingConfig = $("android.signingConfigs.myConfig")
}
}
}
android.signingConfigs {
create("myConfig") {
storeFile "/path/to/debug.keystore"
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
storeType "jks"
}
}
}
了解更多关于分级实验的信息:0.7.0在这里:
https://stackoverflow.com/questions/32898555
复制