Search code examples
androidcordovaionic-framework

Android / Cordova build : how to change minSdk?


I want to publish an app on the play store and make it unreachable for the android < 7.0 / API level 24

This app is an Ionic / Cordova app

First time I published it, without touching anything, got an API lvl 22+. Now I try to set this on 24+.

I tried a lot of things :

  • changing androidManifest.xml with <uses-sdk android:minSdkVersion="24" android:targetSdkVersion="29" /> : the app won't build , log is The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.
  • android/build.gradle : if I change the default value of defaultMinSdkVersion=22, the app builds but won't install
  • android/gradle.properties : there is a cdvMinSdkVersion, but it's already set to 24
  • config.xml - <preference name="android-minSdkVersion" value="24" /> : app builds, the debug build can be installed but the "--prod --release" buld won't install

The app, when it won't insall, can still be run on émulator or on device, it's really the apk's install that fails : how can I get some log on this ?

EDIT : as Marco's answer stated it, config.xml is the file that has to be changed.

The apk wasn't installable because of the process used to create it, saw it when installing with adb install. Following the ionic documentation, I was building using jarsigner + zipalign, but I had to zipalign ( twice ) then apksigner. Don't know why some apk builds was ok though.


Solution

  • The right solution is to change the config.xml file. Why ? Everything under /android/ is build by Cordova and will be modified and/or deleted during next build.

    You might investigate why the app won't install in --prod --release. If you have a different certificate in debug and release, you need to uninstall old apps before installing new ones.