2

I have an Ionic (1.6.4) project with the Android platform that had an ant.properties file with the following:

key.store=mykeystore
key.alias=myalias
key.store.password=mypass1
key.alias.password=mypass2

Previously, I could run ionic build --release and it would build the unsigned apk, then sign it and produce another apk.

Recently, I needed to add the org.apache.cordova.splashscreen plugin which complained about my older version of Cordova, so I upgraded to 5.2.0 from 1.5.0. That, in turn, required I update my Android SDK to get Android 22. The Cordova build process seems to run fine.

[...all the previous steps...]
:packageRelease UP-TO-DATE
:assembleRelease
:cdvBuildRelease

BUILD SUCCESSFUL

However, Ionic now only produces an unsigned release apk.

Any suggestions on what could be causing the problem? Is there a log file I can check that might give me a clue? I know that even before when it worked, if the keystore was completely missing, it would just not sign it and pretend everything was fine (no error), so I thought maybe something similar was happening here and it was just suppressing an error.

Version Details:

cordova -v // 5.2.0
ionic -v // 1.6.4
node -v // v0.12.7
npm -v // 2.13.5
ionic.js // 1.0.1

Things I already tried:

  • ant.properties and keystore are both still there
  • cordova platform upgrade android ran successfully
  • in ant.properties, pointing to keystore using an absolute path, relative path, and simply putting it directly in platforms/android without a path
  • both ionic and cordova commands
  • build --release android and build --release
ben
  • 488
  • 3
  • 11
  • Immediately after posting this I started digging around again for any logs, and discovered that apparently the build process has switched from using ant to using gradle. Do I need to write some new configuration file for gradle? – ben Aug 15 '15 at 14:21

1 Answers1

0

It appears at some point between those software upgrades, some piece of the puzzle switched from using ant to gradle for the build process.

Following the answers on this other question I was able to find out what to do.

First, create a gradle.properties file and fill it in with the appropriate data:

storeFile=...
keyAlias=...
storePassword=...
keyPassword=...

Next, edit the gradle.build file and add the following:

android {
    signingConfigs {
        release
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }

}

if (project.hasProperty('storeFile')) {
    android.signingConfigs.release.storeFile = file(storeFile)
}
if (project.hasProperty('keyAlias')) {
    android.signingConfigs.release.keyAlias = keyAlias
}
if (project.hasProperty('storePassword')) {
    android.signingConfigs.release.storePassword = storePassword
}
if (project.hasProperty('keyPassword')) {
    android.signingConfigs.release.keyPassword = keyPassword
}

Now it signs the release apk properly.

Community
  • 1
  • 1
ben
  • 488
  • 3
  • 11
  • it's build.gradle not gradle.build... but when I open that file it says it's generated and not to edit it. – FlavorScape Jun 07 '16 at 23:22
  • i tried editing the one in the cordova folder, but i get errors with these settings. `A problem occurred evaluating project ':CordovaLib'. > Could not find property 'release' on SigningConfig container.` – FlavorScape Jun 07 '16 at 23:33
  • The initial problem was caused by updating a project started with Cordova 1.5 to Cordova 5.2. Now in 2016 we have Cordova 6.0. It's pretty unlikely this is the exact problem you're having, unless you're also encountering a problem after updating Cordova for the first time since 2014. – ben Aug 15 '16 at 09:37