Question

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?

Was it helpful?

Solution

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 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top