cordova-android: App config.xml does not update AndroidManifest.xml file's versionCode, versionName or anything
Bug Report
App config.xml does not update AndroidManifest.xml file’s versionCode, versionName or anything
Problem
I have changed app version, add some meta-data at android scope in config.xml file but after build it does not update android ‘AndroidManifest.xml’ file. I still see the previous value and meta-data in ‘AndroidManifest.xml’.
What is expected to happen?
changing on app config.xml file [app version, meta-data], should be changed in android ‘AndroidManifest.xml’ file after build.
What does actually happen?
After changing app config.xml file widget version, meta-data, when the build finished nothing updated in AndroidManifest.xml file. And it shows no error, warning in build console/terminal. Build was success.
Information
Changes on config.xml file data [app widget version], it changes automatically app version for the first couple of builds but after 6-7th time cordova build it does not automatically update. ‘AndroidManifest.xml’ so my android build version not updating and meta-data not added. Screenshot attached
- App config.xml file
- AndroidManifest.xml file after cordova build, it still showing previous properties
Command or Code
ionic cordova build android
Environment, Platform, Device
Ionic:
ionic (Ionic CLI) : 4.0.1
Ionic Framework : ionic-angular 3.9.4-201903121725
@ionic/app-scripts : 3.1.8
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4, browser 5.0.4, ios 4.5.4
System:
Android SDK Tools : 26.1.1
ios-deploy : 1.9.4
NodeJS : v10.15.1 (/usr/local/bin/node)
npm : 6.4.1
OS : macOS High Sierra
Xcode : Xcode 10.1 Build version 10B61
Environment:
ANDROID_HOME : /Users/bs228/Library/Android/sdk
Version information
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 3
- Comments: 16 (3 by maintainers)
I found the code that cause bug:
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest">
<manifest xmlns:tools="http://schemas.android.com/tools" />
</edit-config>
In my case I have a monorepo with one cordova setup and multiple Ionic apps with shared code base. Anyway, as I see, the app id is embedded anywhere in files and path name in platforms folder. I know that this issue is about the version, now. But initially also about the app-id. So just for clarification and self-interest:
I found some files in platforms folder with the app-id:
app/src/main/res/xml/config.xml
app/src/main/java/your/app/id/MainActivity.java (app id in path name)
android.json
You see that the app-id occurs in some files and folder names. I don’t know why Google chose this architecture. In my opinion it should be one source for these meta data. But anyway…
It’s hard to update all this existing data. You we have to remove the platforms folder when changing meta data like the app id. The downside is that the build will take more time to get these files again. I doubt we can find a better solution here, right?
Please correct me if I’m wrong or missed something. What files / folder should be removed when the app-id, name, etc. are changed? Only the platforms folder?
Is there a way to detect this via Cordova? Show a warning that the app-id, etc. of config.xml does not match the platforms files. The current behavior is either confusing (not related) error or no error. In some cases you can detect an issue when trying to run the app. (instant crashes). It’s annoying. …
Spontaneous solution: Store the meta data (app id, etc.) in a separate file to detect changes. Remove the related platforms folder before build, when data have been changed. This can be archieved with an own custom build script. (just thinking aloud). Or check the android.json (or another file in platforms) to check the app-id. Or just remove the platforms folder before every build. But that can delay development time. …
Ideas are welcome. … We could add a new CLI option to rebuild the platforms files. In best case just related files / folders. But Cordova should detect changes and rebuild the platform automatically. Or is it possible to set different paths for different app-ids? e.g. a CLI option. Set path for the platforms folder.
Also facing this issue
I’m also facing this issue any ideas?
Is there any update on this, as this issue seems to be occurring still. I am experiencing this exact problem. On the first several builds, cordova seems to take the version number from config.xml, but after that it just refuses and doesn’t read the config.xml value anymore.
Has any fix been done for this, as I’m sure this is an issue many people are running into.
Below is my env info.
`
`
@dpogue, okay I understand about the project ID. But my problem was, I changed the app version to 0.2.62 in config.xml file
After the android build success it still showing the old version 0.2.55, it doesn’t get updated in AndroidManifest.xml file. So I’m unable to change the apk version.