I'm completely stuck with a crazy issue. I'm not able to publish an update of my app in Google Play store because current version code is 101002.
Now, I don't understand how that code was generated. In my config.xml I tried using the following versions:
1.3
1.3.1
1.3.1.1
but every time it generates a version code like:
10300
10310
10311
that is always lower than the current version code: 101002
I also tried to build using the following command:
ionic cordova build android --prod --release -- -- --versionCode=103020
but it doesn't work
I can't manually set the version code of the Manifest file because it's generated by ionic 2 build process. Any idea?
You can specify a custom version-code in config.xml. Add the following property to the <widget> element (the root element): android-versionCode="101003".
This is an example of a full <widget> tag with more properties that are probably useful:
<widget android-versionCode="100" id="your.bundle.id" ios-CFBundleVersion="1.0.0" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
version is the version displayed in the app stores, can stay the same across different builds
android-versionCode this is used by Google-Play to differentiate between your builds, must always be higher than the previous one
CFBundleVersion is used by iTunesConnect to differentiate your builds, must always be higher than the previous one
id is where you define the bundle identifier of your app, this must always stay the same
If you compile your project with Android Studio, you can change it in the App-> Manifests-> AndroidManifest.xml folder
Related
I'm building an app which name starts with a number "100 Times". But when I try to add the Android platform:
ionic cordova platform add android
I get the following error:
CordovaError: Error validating project name. Project name must not begin with a number
My config.xml is like:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.times100" ...>
<name>100 Times</name>
...
</widget>
As far as I know it is not a Google Play restriction, cause there are a lot of apps with names that starts with numbers.
How can I use an application name that starts with a number with Cordova?
I was able to use numbers at beginning of my app name following the steps below:
Create the android studio project running "cordova prepare android"
Open the Android Studio Project and edit "res/values/strings.xml"
Replace the "app_name" node content with the name you want.
Build the APK using Android Studio.
That's a cordova bug. There is an issue for that:
https://github.com/apache/cordova-android/issues/584
There's also a pull request to fix it in version 9.x of cordova-android:
https://github.com/apache/cordova-android/pull/859
For now the only way is to use some (hackish) workaround to fix that.
I generate the apk in a CI environment using docker containers, so executing commands manually in Android Studio was out of question in my case, so I forked the cordova-android repo, commented the lines that does that unnecessary (and wrong) validation and installed the android plugin in my project from the forked github repo.
Trying to upload the Cordova build using Fastlane Supply fails with this error:
Google Api Error: multiApkShadowedActiveApk: Version 10125 of this app
can not be downloaded by any devices as they will all receive APKs
with higher version codes.
It might've started happening after I updated to cordova-android 6.0.0. Can't be sure tho.
One thing I might add is that I don't specify that 10125 style of version anywhere in the project. I only update the version attribute inside widget tag to X.X.X versioning style.
It turns out, cordova-android changed how it calculates the versionCode out of the version value inside the widget tag.
The solution is to manually specify versionCode:
<widget version="1.1.26" android-versionCode="101260" ... >
Is there a way to do this without deleting and re-installing the platforms directory?
The reason I'm asking is that I'm trying to generate two APKs with different bundle IDs -- one for Development and one for Production. The bundle ID is being read correctly from the config.xml file at the root of the project and updated in the <manifest> tag. However, I have the cordova-push-plugin installed which requires an android:name XML attribute of the form PACKAGE_NAME.permission.C2D_MESSAGE and the bundle ID part of this property is not being updated with the bundle ID found in config.xml.
It looks like the Cordova build process for Android looks at the PACKAGE_NAME property in the platforms/android.json file and uses that to insert permissions into the AndroidManifest.xml file. Is there a way to update this?
edit: I'm using Ionic to build my project and use the ionic state reset command to delete/add the platforms back.
i would like to change default name of the installation package from default com.ionicframework.starterto com.something.something, how can i do it safely please? What i should to edit?
Thanks for any advice.
You should make this change in the config.xml found at the root of your project. For example you might have something like this:
<widget id="com.ionicframework.exampleproject223738" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
Change the id to whatever you wish your package to be and it will work for the entire project, Android and iOS.
However, if you've already submitted to the app store with a package name, you cannot change the package name at this point. Not unless you want to submit a new project. Updates must be made with matching package names.
Regards,
All I did was:
a) Go to MainProjectFolder -> config.xml and find the line which says
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
b) Change the io.ionic.starter to com.myproject.mobile (reverse domain - that's what they call it, right)
c) Save the file.
d) Delete the platforms folder.
e) Open the command prompt and
- platform add android
- build android
-> build --release android
-> generate key using keytool
-> sign the apk using jarsigner
-> optimize the code using zipalign (for great documentation on these commands, refer: https://ionicframework.com/docs/v1/guide/publishing.html.
f) This process takes the package name from the config.xml file and build the apk from scratch thus eliminating the need for resetting any plugins as suggested. But I am new to this. May be there are other implications which experienced guys might point at. But this worked very well for me and I have deployed my first mobile app onto Google Playstore successfully.
Hope this helps.
This is what I did,
Change the package name in config.xml
enter "ionic repair"
That's it.
It removes/adds platform, removes/adds node packages and does other stuff, but everything will be automatic.
Changing the package name in config.xml is the first step, there are other steps that need to be done to address the op's question about 'safely' changing the package name.
#ananth has given the practical answer. However it can be further simplified as I have tested and verified on Ionic 3.
Change package name in config.xml
Delete a platform, ionic cordova platform rm <platform>
Add the platform back, ionic cordova platform add <platform>
If the platform was Android, regenerate the signing key. This page (https://forum.ionicframework.com/t/how-to-automatically-sign-android-applications-with-the-ionic-cli/87449) gives the simplest and safest process.
One should just update the package name in config.xml and reinstall all the plugins ionic state reset -- plugins ; caution ensure all the plugins are listed in package.json.
I'm using cordova cli to build my app. I want to target both android and ios (maybe more).
As I want this to be true for all platforms, I was hoping I could simply define this as a preference in the config.xml like this:
<preference name="orientation" value="landscape" />
because this is apparently how it works in the phonegap build https://build.phonegap.com/docs/config-xml
I assume the features supported in config.xml by phonegap build are different to those by cordova-cli?
I know I can force it in the android app by inserting android:screenOrientation="landscape" into my AndroidManifest.xml, but that's no good because it will be over-written the next time I perform a cordova build.
Any suggestions?
This is no longer the case. The "orientation" preference in the config.xml is now honored by the cordova cli starting from version 3.4
This is the corresponding issue : https://issues.apache.org/jira/browse/CB-5634
Simply put, it's not possible to set the orientation using a preference element in the www/config.xml. After inspecting the cordova-cli code it appears that only the version and entry class package are updated in the AndroidManifest.xml.
For a list of supported preferences see the Cordova Docs.
Added configurations to the AndroidManifest.xml file should not be lost on cordova build, unless the config option is pulled from somewhere else (i.e. version).