Я попытался установить свое приложение на Android версии 12. Я добавил android:exported для каждого действия, получателя и фильтров. Эта ошибка возникает
Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
List of apks:
[0] 'C:\Users\Code\MyApp\app\build\outputs\apk\debug\app-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
В объединенном манифесте отображаются эти ошибки
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
Это тестовый файл AndroidManifest.XML, который вызывает ошибки
<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>
Это тестовые зависимости, которые я использую
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')
Проблема возникает в тестовом пакете и автоматически генерируется. Как это исправить?
Я пробовал несколько решений, чтобы решить проблему, но, похоже, ничего не решает ее.
Вот некоторые решения, которые я изучил, но не сработали для меня.
@CommonsWare Я включил тестовый файл манифеста, который вызывает ошибку. Эта активность androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity находится в тестовом пакете, где я не могу ее редактировать.




Ошибка была исправлена путем изменения этой версии зависимости androidx.fragment:fragment-testing
с версии 1.3.5
debugImplementation 'androidx.fragment:fragment-testing:1.3.5'
до версии 1.4.0
debugImplementation 'androidx.fragment:fragment-testing:1.4.0'
Этот ответ помог мне исправить ошибку https://stackoverflow.com/a/71605255/9770844
Почему вы используете debugImplementation, а не директиву для конкретных тестов (testImplementation для модульных тестов, androidTestImplementation для инструментальных тестов)?
@CommonsWare Я не уверен, почему предыдущий разработчик использовал его, но я предполагаю, что у них был отладочный компилятор. Но, насколько мне известно, документация Android предлагает это developer.android.com/guide/fragments/test#groovy
«Проблема возникает в тестовом пакете» — что именно вы подразумеваете под этим? Кроме того, я рекомендую опубликовать ваш манифест, по крайней мере запись
<activity>дляcom.example.myapp.authactivity.Splash.