Cordova: Is it possible to have different app IDs for android and ios platforms?
Asked Answered
F

2

27

Let's say I have a Cordova application with an id of com.StackOverflowExample.MyQuestion, which I created with Cordova 3 using the CLI (cordova create). I have added iOS and Android platforms for my app, and have submitted the app to Apple and to Google Play. Now, however, after submitting my app to Play, I seem to have misplaced my password for the keystore I used to sign my APK file. I have tried everything, and there is no way I will recover it.

Because Google Play does not allow me to sign a subsequent APK submitted to Play under the same app ID as a prior APK signed by a different keystore, I know I need to create a new app ID and start over in Android. I realize this will require my users to download a new application, but I have no other choice at this point.

What I would like to avoid, is having this problem spill over into Apple, where I have already created all of my certificates, provisioning profiles, keys, signing requests, etc. and uploaded an IPA with a bundle identifier the same as the app ID of the first APK I submitted to Google Play.

By default, when using the CLI, Cordova adds whatever platforms you specify using a single app ID, which you supply when you run cordova create.

What I'd like to know is: Is it possible, when running cordova platform add to add a new platform under a custom app ID, and, as a result, to have different platforms have different app IDs within the same Cordova application?

Foodstuff answered 28/9, 2013 at 17:22 Comment(0)
M
57

This is now built into CLI (finally):

In you your config.xml file-

Example:

<widget
    android-packageName="com.example.android"
    ios-CFBundleIdentifier="com.example.ios">

Source:

https://github.com/apache/cordova-common/blob/master/src/ConfigParser/ConfigParser.js#L105-L113

Merline answered 9/1, 2015 at 20:59 Comment(2)
The repository and the file itself was moved. Current link would be Currently latest revision or master version - might change in the futurePittance
File is now part of cordova-common - new locationPhalan
L
-3

Yes, you can do that. There is more option for them, it's depends on how do you build your Android application (how do you create your apk).

If you create the apk using cordova, first you have to decode your apk:

apktool d <apkname>.apk <directory to decode>
e.g: 
apktool d your.apk decodedir

Change the package="com.StackOverflowExample.MyQuestion" string in AndroidManifest.xml.

Encode your apk:

apktool b <directory> <new apk name>
e.g:
apktool b testdir/ your.repacked.apk

If you create the apk using any Android developer tools, you can change the id in the appropriate xml file (AndroidManifest.xml), and build the app.

Limey answered 20/10, 2013 at 1:31 Comment(2)
Morris, did this work for you? I have exactly the same issue here and I'm searching for an automated way to do this...Smock
I ended up doing a new app ID for both iOS and Android to fix the problem, as there weren't any responses when the issue was current for me.Foodstuff

© 2022 - 2024 — McMap. All rights reserved.