I tried to install my application in an Android version 12. I added the android:exported
for each activity, receiver and filters. This error occurs
Installation did not succeed. The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED List of apks: [0] 'C:UsersCodeMyAppappbuildoutputsapkdebugapp-debug.apk' Installation failed due to: 'Failed to commit install session 366841949 with command package install-commit 366841949. Error: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl366841949.tmp/base.apk (at Binary XML file line #392): androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present' Retry Failed to launch an application on all devices
The merged manifist displays these errors
Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. myapp.app main manifest (this file), line 26 Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. muapp.app main manifest (this file), line 33 Error: android:exported needs to be explicitly specified for element <activity#androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. myapp.app main manifest (this file), line 40
This is the test AndroidManifest.XML file that causes the errors
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="androidx.test.core" > <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="28" /> <uses-permission android:name="android.permission.REORDER_TASKS" /> <application> <activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity" android:theme="@android:style/Theme" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity" android:theme="@android:style/Theme" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> <activity android:name="androidx.test.core.app.InstrumentationActivityInvoker$EmptyFloatingActivity" android:theme="@android:style/Theme.Dialog" > <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> </activity> </application> </manifest>
These are the test dependencies I’m using
debugImplementation 'androidx.fragment:fragment-testing:1.3.5' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0') androidTestImplementation('androidx.test:runner:1.4.0') androidTestImplementation('androidx.test:rules:1.4.0')
The problem occurs in the test package and its auto generated. How to fix it?
I tried multiple solutions to fix the problem but nothing seems to fix it.
These are some solutions I looked into but didn’t work for me.
- Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]
- An API level of 31 is not supported by this compiler. Please use an API level of 30 or earlier
Advertisement
Answer
The error was fixed by changing this dependency version androidx.fragment:fragment-testing
from version 1.3.5
debugImplementation 'androidx.fragment:fragment-testing:1.3.5'
to version 1.4.0
debugImplementation 'androidx.fragment:fragment-testing:1.4.0'
This answer helped me fix the error https://stackoverflow.com/a/71605255/9770844