Question

I have a project with following structure:

Root
    \__main_project
    |
    \__modules
       \__
       |  library1
       |   
       \__
          library2

I have following config in my gradle:

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.0'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }

    signingConfigs {
        release {
            storeFile file('/home/home/.signing/test.keystore')
            storePassword 'testtest'
            keyAlias 'testtest'
            keyPassword 'testtest'
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

to build my project I run following command:

./gradlew :main_project:assembleRelease

but it only produces main_project-release-unsigned.apk

So my question why it produces unsigned apk when I specified all required configuration. Thank you.

Was it helpful?

Solution

The "official" way to configure the build.gradle file as recommended by Google is explained here.

Basically, you add a "signinConfig", in where you specify the location an password of the keystore. Then, in the release build type, refer to that signing configuration.

...
android {
    ...
    defaultConfig { ... }
    signingConfigs {
        release {
            storeFile file("myreleasekey.keystore")
            storePassword "password"
            keyAlias "MyReleaseKey"
            keyPassword "password"
        }
    }
    buildTypes {
        release {
            ...
            signingConfig signingConfigs.release
        }
    }
}
...

Then build the app with the "assembleRelease" task.

OTHER TIPS

Try ./gradlew assembleRelease.

Also you'll probably want to augment the buildTypes release section

buildTypes {
    release {
        runProguard true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.txt'
        signingConfig signingConfigs.release
        zipAlign true
    }
}

Also see task askForPasswords on How to create a release signed apk file using Gradle? for how to prompt for the passwords so they aren't stored in this file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top