I have successfully modified my build.gradle to work with gradle-experimental however when trying to add a signingConfigs block it fails. I followed the instructions from http://tools.android.com/tech-docs/new-build-system/gradle-experimental as best I can but i always get the following error:
A problem occurred configuring project ':app'.
The following model rules are unbound:
model.android.signingConfigs > named(release)
Mutable:
- android.signingConfigs.release (com.android.build.gradle.managed.SigningConfig)
I search for the error but couldn't find anything relevant. What does "The following model rules are unbound" mean?
Here's what my signingConfig block looks like, it's outside the android block and modified to use = as is the case when using gradle-experimental.
android.signingConfigs {
release {
storeFile = file("myreleasekey.keystore")
storePassword = "password"
keyAlias = "MyReleaseKey"
keyPassword = "password"
}
}
Although, it's late for the user who asked this question, still it may help others.
Following code sample is working fine for me. I tested it with following settings - Gradle-experimental-0.4.0, Gradle wrapper - 2.8, Android Studio 2.0 Preview edition.
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. - it's not working with minifyEnabled = true
, in which case a error related to transformClassesAndResourcesWithProguardForRelease
occurs.
Edit - 1. minifyEnabled = true
is working with above settings. Turns out I had my proguard-rules file was empty, and somehow it was causing the mentioned error.
Here is how to add signing for gradle experimental 0.7:
apply plugin: "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"
}
}
}
Find out more info about gradle experimental:0.7.0 here:
Experimental Plugin User Guide