1

I'm about to deploy a hybrid app using phonegap (for android & ios). We want to swap it without the users knowing, so I thought I can just use the same device id (eg "de.company.myapp") - and so this way after the next app store update the users will have the new app installed.

Note that on iOS this doesn't seem to be a problem.

cordova config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns     = "http://www.w3.org/ns/widgets"
    xmlns:gap = "http://phonegap.com/ns/1.0"
    id        = "de.company.myapp"
    version   = "1.0.0">
...

While testing this with android I'm getting this error: (note that the old native app is already installed on the device)

...
Installing app on device...
>> 
>> /path/to/cordova/platforms/android/cordova/node_modules/q/q.js:126
>>                     throw e;
>>                           ^
>> ERROR: Failed to launch application on device: ERROR: Failed to install apk to device:   pkg: /data/local/tmp/Fahrschulcard-debug-unaligned.apk
>> Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]

So this means the apk signatures don't match. After deleting the old app I can of course just install the new one, but there are a lot of android users using the old app, so telling them all to first delete the old one would be terrible.

Questions:

So it is possible to use the same cert/signature as the one used to build the native app?

Does anyone have experience with this kind of requirement, is this possible at all?

fr00t
  • 681
  • 1
  • 4
  • 19
  • Are you sure you signed your apk with the same certificate you were using with native app? You seem to be running the debug apk, not the release-signed-and aligned one. – QuickFix Jul 29 '14 at 13:08
  • Sorry if this wasn't clear. I did run the debug apk. But it looks like I will need to have the private key used to sign the old native app? http://stackoverflow.com/questions/4843212/the-apk-must-be-signed-with-the-same-certificates-as-the-previous-version – fr00t Jul 29 '14 at 13:35
  • Right. To publish on google play, you need to make sure you disabled debug in android manifest, build your app, sign it with the same key you used with the old native app (android checks that the certificate is the same to allow update) and to align it. That way when you publish the new cordova app on the store, the users will be automatically updated (unless your new app requires some permissions the old app did not). I think there may be a way to change the certificate for an app (I think we had to do it but don't remember how). May be check google play docs. – QuickFix Jul 29 '14 at 14:05

1 Answers1

1

To answer my own question, 2 things were needed to fix this problem:

  1. you will need the original *.keystore file with which the old native app was signed (together with the password)
  2. Make sure to disable debug option in your android manifest

For cordova builds, you will have to create a file called ant.properties like described in this post.

As soon as you created the ant.properties file you just need to run the following command to create the signed release-ready apk file platforms/android/ant-build/appname-release.apk:

$ cordova build android --release 
fr00t
  • 681
  • 1
  • 4
  • 19