Can't build apk for Android 12. Cordova

Viewed 1445

Please help me with a problem

When I try to install the application after building it on Android 12 emulator, AndroidStudio throws errors for some services:

Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed pars e during installPackageLI: /data/app/vmdl1492588574.tmp/base.apk (at Binary XML file line #105): com.adobe.phonegap.push.FCMService: Targeting S+ (version 31 and above) requires that a n explicit value for android:exported be defined when intent filters are present]

To avoid this error I add android:exported="false" Like this

<service android:exported="false" android:name="com.adobe.phonegap.push.FCMService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

But because of this, an error appears already at the time of building the apk and the service is duplicated in the AndroidManifest below:

Element service#com.adobe.phonegap.push.FCMService at AndroidManifest.xml:29:9-33:19 duplicated with element declared at AndroidManifest.xml:19:9-23:19

2 Answers

It looks like the plugin you are using is not compatible with Android SDK 31. Either change the build target to SDK 30, or ask the maintainer to update the plugin.

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

Everytime you change some code you have to check your manifest and remove duplicate lines from it. It happens when you add the exported value='true/false'.

Related