pedrovgs / Shot

Screenshot testing library for Android
Apache License 2.0
1.19k stars 116 forks source link

Gradle tasks fail when targetSdkVersion is 31 #296

Closed BsBrabi closed 2 years ago

BsBrabi commented 2 years ago

Expected behaviour

All gradle tasks work when targetSdkVersion is set to 31.

Actual behaviour

./gradlew executeScreenshotTests -Precord fails with the following error message:

Package name 'xxx.test' used in: AndroidManifest.xml, tempFile1ProcessTestManifest9525208819929064971.xml.
/xxx/app/build/intermediates/tmp/manifest/androidTest/integration/debug/tempFile2ProcessTestManifest17963238976791642597.xml Error:
android:exported needs to be explicitly specified for <activity>. 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.

Steps to reproduce

Reproducable with sample app, when all targetSdkVersion and compileSdkVersion are set to 31.

Version of the library

5.13.0

MyDogTom commented 2 years ago

@BsBrabi Is it only about sample app or your own app as well? If it's about your app, then I think you should be able to fix it without changing Shot library.

android:exported needs to be explicitly specified for

I suspect that this error is not related to the Shot library. Could you please try to run ./gradlew assembleDebugAndroidTest and let me know if you see the same error or not.

The reason for this error is behavior change in Android 12

If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported attribute for these app components.

https://developer.android.com/about/versions/12/behavior-changes-12#exported

BsBrabi commented 2 years ago

Sorry, looks like it really is a problem in our app. I just tried the Shot library with another app sample, and I got it working.