Going crazy - can not deploy APK over API 31

Hi guys, I’m stuck on this, I’ve been working for years on this guitar project it’s almost finish
but I don’t know why I can’t deploy it anymore.

Even after reinstalling everything …

I can’t not afford to migrate to V6, not right now …

A couple of weeks ago I did add to my config.xml:

But that does not the trick anymore, still having:

Installation failed due to: 'Failed to commit install session 2047383350 with command package install-commit 2047383350. Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl2047383350.tmp/base.apk (at Binary XML file line #30): *******.music.jgv.MainActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'

I must missing something, because it did work before …

Thanks for help !

here’s is my ionic info:

cli packages: (/home/iron-man/Voicings/node_modules)

@ionic/cli-utils  : 1.9.0
ionic (Ionic CLI) : 3.9.0

global packages:

Cordova CLI : 10.0.0 (cordova-lib@10.1.0) 

local packages:

@ionic/app-scripts : 3.2.4
Cordova Platforms  : android 9.1.0
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v12.13.0
npm               : 6.12.0 
OS                : Linux 5.15

Have you tried modifying your AndroidManifest.xml file directly and/or verified the Cordova config is in fact updating it?

It’s clear that Cordova config is updating it, but as regards modifying directly the AndroidManisfest.xml
how can I do that since it’s a binary file once builded in release mode ?

thx

I was referring to updating it directly before building the APK instead of using Cordova’s config.xml file.

What does your AndroidManifest.xml file look like?

I had to add android:exported in two spots in mine. One under manifest.application.activity and the other manifest.application.provider.

Unfortunately I am using Capacitor and can’t help with Cordova specifics. In Capacitor land we just update AndroidManifest.xml directly.

this is my xml:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="233" android:versionName="0.2.33" package="zubicaray.music.jgv" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:exported="true" android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

* List item

It seems you save my week ! thx a lot twestrick

I’ve just added android:exported=“true” right after activity

<activity android:exported="true" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:exported="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

So here are my steps:

  1. ionic cordova platform remove android
  2. ionic cordova platform add android
  3. modify platforms/android/app/src/main/AndroidManifest.xml accordingly
  4. cordova build android --prod --release
1 Like

Instead of adding the exported attribute yourself, update your app to cordova-android 11 as it adds it and also targets SDK 32 by default.

Instead of ionic cordova platform add android do ionic cordova platform add android@latest to get latest version instead of the pinned version.

1 Like

Thx Julio, but that does not work for me.
I did try before …

And retry today, after having fully rebuilded everything, but still not working.

if you can, move to capacitor

1 Like

I 've made a reattempt, set right gradle and move to java 11
which I did before, but this time I solved some java compilation issue following:

ionic cordova plugin add cordova-plugin-androidx
ionic cordova plugin add cordova-plugin-androidx-adapter`

now it works, thx a lot