Problems with Android10 on an Ionic4+cordova app

I have in production an Ionic4 app, that uses a lot of Cordova plugins:

phonegap-plugin-barcodescanner 8.0.1 "BarcodeScanner"
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter"
cordova-plugin-appavailability 0.4.2 "AppAvailability"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-googlemaps 2.6.2 "cordova-plugin-googlemaps"
cordova-plugin-inappbrowser 3.2.0 "InAppBrowser"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-ionic-webview 4.1.0 "cordova-plugin-ionic-webview"

I can see that this app, on some devices with Android 10, has some problems:

  • the geolocation doesn’t work well (takes a lot of time to get the right position),
  • the camera plugin and the barcodescanner plugin some time crush when opened.

On Android 9 we don’t have all these problems.
How can I deal with this problem?

Thank you very much


Probably I have to specify Android target: android-29.

How can I change the Android target?

>ionic cordova platform add android
> cordova.cmd platform add android
Using cordova-fetch for cordova-android@^8.1.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: it.bitmobility.bit
        Name: BIT
        Activity: MainActivity
        Android target: android-28

I don’t know if this solves the Problem you have, but as you can read here there is a Preference android-targetSdkVersion that you can set to 29:

<preference name="android-targetSdkVersion" value="29" />

btw, cordova-android version 9.0.0 was released a few weeks ago, which sets this automatically:

1 Like

Yes I’ve installed the new cordova-android version 9.0.0

ionic cordova platform rm android
ionic cordova platform add android@latest

and added these lines to config.xml:

    <preference name="android-minSdkVersion" value="22" />
    <preference name="android-targetSdkVersion" value="29" />

Now it should work better on Android 10.

You can remove the line for the default target as it is default in cordova-android@9.0.0

1 Like