1

If I use Android Studio's "Generate Signed APK" from the Build menu it works and generates a signed apk. The problem is the apk is not generated if I try to run

./gradlew clean build assembleRelease

I've configured my build.gradle like this:

signingConfigs {
    release {
        //set values in ~/.gradle/gradle.properties to sign with your own keystore and certificate
        storeFile file(project.hasProperty("KEYSTORE_FILE") ? KEYSTORE_FILE : "/")
        storePassword project.hasProperty("KEYSTORE_PASSWORD") ? KEYSTORE_PASSWORD : ""
        keyAlias project.hasProperty("KEY") ? KEY : ""
        keyPassword project.hasProperty("KEY_PASSWORD") ? KEY_PASSWORD : ""
    }
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        signingConfig signingConfigs.release
    }
}

lintOptions {
    abortOnError false
}

My gradle.properties file looks like these:

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.daemon=true

KEYSTORE_FILE=/home/user/Documents/programs/keystoreAndroidStudio/keystore.jks
KEYSTORE_PASSWORD=xxxxxx yyyyy
KEY=Client
KEY_PASSWORD=xxxxx yyyyy

What am I doing wrong?

EDIT: I also tried feeding the signing params directly to gradlew but it doesn't work either.

./gradlew assembleRelease -Pandroid.injected.signing.store.file=$KEYFILE -Pandroid.injected.signing.store.password=$STORE_PASSWORD -Pandroid.injected.signing.key.alias=$KEY_ALIAS -Pandroid.injected.signing.key.password=$KEY_PASSWORD

I'm starting to think that it is something related to my passwords containing a space. I tried giving the previous command a wrong password and it didn't complain, it still said BUILD SUCCESSFUL

Julio Vga
  • 143
  • 1
  • 7
  • Possible duplicate of [How to create a release signed apk file using Gradle?](http://stackoverflow.com/questions/18328730/how-to-create-a-release-signed-apk-file-using-gradle) – OneCricketeer Aug 01 '16 at 15:47
  • Looks like you've done all the correct things from that post... What files are being generated? – OneCricketeer Aug 01 '16 at 15:49
  • Nothing is being generated. I noticed that when I do it through Android Studio it executes project-b:assembleRelease so I also tried with that through the command line and didn't work. – Julio Vga Aug 01 '16 at 16:09
  • You seem to just be running `assembleRelease`, not `project-b:assembleRelease` – OneCricketeer Aug 01 '16 at 16:45
  • I tried both but the problem persists – Julio Vga Aug 01 '16 at 17:00

1 Answers1

0

It would help to know which gradle version you are using.

Here is a page to get the latest gradle (I recommend to bookmark this page).

I faced similar gradle issues in the past (e.g. here), so my advice is: change the gradle version, clean and rebuild.

PS: I know that my answer is quite vague, but for me the page (linked above) was often a life-saver, so it can't harm to share this info.

Community
  • 1
  • 1
Martin Pfeffer
  • 12,471
  • 9
  • 59
  • 68
  • Thanks for the advice. I'm using "classpath 'com.android.tools.build:gradle:2.1.2'" which I think is the latest stable version but still no luck – Julio Vga Aug 01 '16 at 16:57