Search code examples
androidcordovaapkandroid-manifestandroid-12

Can't build apk for Android 12. Cordova


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


Solution

  • 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" />