Ionic v3 app started crashing on Android 6 after migrating to cordova 12

Hi,
After updating my app to Cordova 12 (which I did in order to target SDK 33) it started crashing on startup on Android 6 (or more precisely 6.0.1).

I have no idea where to start, because it crashes right at the very startup before I’m able to connect using Chrome’s chrome://inspect/#devices.

Is there anything I can do to debug this?

P.S. On newer Android phones I’ve been able to get my hands on (12, 13…) it works OK.

Ionic:

   Ionic CLI          : 6.20.9 (C:\Users\Aros\AppData\Roaming\nvm\v16.20.2\node_modules\@ionic\cli)
   Ionic Framework    : ionic-angular 3.9.5
   @ionic/app-scripts : 3.2.2

Cordova:

   Cordova CLI       : 12.0.0 (cordova-lib@12.0.1)
   Cordova Platforms : android 12.0.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, (and 4 other plugins)

Utility:

   cordova-res : not installed globally
   native-run  : 2.0.1

System:

   Android SDK Tools : 26.1.1 (c:\Users\Aros\AppData\Local\Android\Sdk\)
   NodeJS            : v16.20.2 (C:\Program Files\nodejs\node.exe)
   npm               : 8.19.4
   OS                : Windows 10

Thanks!
Jan

Yeah, debug through Android Studio and look at its logs.

OK, thanks… As silly as it may seem, I had never actually realized there’s and Android studio project in the platforms/android folder. All these years I’ve been building with ionic cordova run android and then debugging using chrome…

Anyways, OK. I’ve opened the project in Android studio. This is my first experience with actually using it (apart from installing SDKs) so I am a bit confused on how things work in there, but it look like it crashes somewhere in CordovaActivity::init(). There’s a line that says

// Setup the splash screen based on preference settings
cordovaInterface.pluginManager.postMessage("setupSplashScreen", splashScreen);

If I step in to the postMessage it ends on trying to execute forEach on the pluginMap, I have no idea what’s wrong. I cannot see any logs and the debugging session just ends in there and on the phone display there appears a popup message that the app stopped working (or something like that, the phone is not in English so I am just guessing what the message would be in English) and that’s it.

I would expect the debugger to stop on the exception, but it doesn’t. Is this normal?

BTW this is the content of the pluginMap by the time it tries to call the forEach on it:

this.pluginMap = {Collections$SynchronizedMap@5080}  size = 9
 "CordovaAllowListPlugin" -> {AllowListPlugin@5101} 
 "CordovaSplashScreenPlugin" -> {SplashScreenPlugin@5103} 
 "Device" -> null
 "Globalization" -> null
 "NativeStorage" -> null
 "StatusBar" -> {StatusBar@5108} 
 "Insomnia" -> null
 "Keyboard" -> null
 "CoreAndroid" -> {CoreAndroid@5112} 

Any ideas how to proceed?

Thanks!
Jan

Logcat in Android Studio should show some sort of error I would think. That is where all logging goes.

I am unfortunately not familiar with Cordova to help out with that specifically. You should think about switching to Capacitor :wink:

cordova-android 12 doesn’t support Android 6, the minimum SDK supported is 24 (Android 7)

1 Like

Hm, interesting. Though I have <preference name="android-minSdkVersion" value="21" /> and it doesn’t complain.

Moreover, looking at the documentation here, even Cordova 11 did not support SDK 21 and it did work just fine.

Will try to have a look at the Logcat thing in the meantime…

OK, so indeed the exception is listed in the Logcat tab. Sorry for such a newbie problem. I’ve been looking at the debugger console tab instead all the time and wondered…

Looking at the exception though I found a github issue explaining the problem. Specifically, it’s this post.

…which indeed boils down to the aforementioned fact that sdk 21 support has been completely dropped in cordova-android 12. Although officially it was not supported even in version 11, there was still a backwards compatibility check which was removed in 12.

Thanks guys. Although I cannot easily solve it and will have to drop support for Android 6, I at least learned how to debug in Android Studio. And potentially this thread may be helpful to someone…

1 Like