KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.34k stars 648 forks source link

All tests fail on Android SDK >=34 (and probably >=31) #842

Closed cmannett85-arm closed 1 year ago

cmannett85-arm commented 1 year ago

Running on SDK v26 caused no problems, but I had to upgrade to v34 for some Android 14 testing, and now all tests fail with this in logcat:

D/CompatibilityChangeReporter(18438): Compat change id reported: 160794467; UID 10306; state: ENABLED
E/AndroidRuntime(18438): FATAL EXCEPTION: Thread-2
E/AndroidRuntime(18438): Process: com.khronos.vulkan_samples, PID: 18438
E/AndroidRuntime(18438): java.lang.IllegalArgumentException: com.khronos.vulkan_samples: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
E/AndroidRuntime(18438): Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
E/AndroidRuntime(18438):    at android.app.PendingIntent.checkPendingIntent(PendingIntent.java:450)
E/AndroidRuntime(18438):    at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:566)
E/AndroidRuntime(18438):    at android.app.PendingIntent.getActivity(PendingIntent.java:552)
E/AndroidRuntime(18438):    at android.app.PendingIntent.getActivity(PendingIntent.java:516)
E/AndroidRuntime(18438):    at com.khronos.vulkan_samples.NativeSampleActivity.fatalError(NativeSampleActivity.java:81)

It's probably a trivial change somewhere so I'll start looking at it. I'm reporting here in case anyone else comes across it, or maybe as a prompt if someone else (I'm looking at you Google) has fixed it but not upstreamed yet.

cmannett85-arm commented 1 year ago

Hmm, it's already set...

// app/android/java/com/khronos/vulkan_samples/NativeSampleActivity.java
PendingIntent pi = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
SaschaWillems commented 1 year ago

Could this be related to this: https://developer.android.com/guide/topics/manifest/activity-element#exported?

cmannett85-arm commented 1 year ago

Possibly, I noticed that it works fine if launched directly from Android Studio (via the 'play' button), but not if launched via the phone's UI. I'm not sure what the difference between them is.

cmannett85-arm commented 1 year ago

Setting exported to false and removing the intent filters results in some tests passing and others failing for the same reason. Which I don't understand.

cmannett85-arm commented 1 year ago

So I had managed to confuse myself somewhat, I was actually running Vulkan-Samples compiled with SDK 33 and NDK 25c on Android 14. Re-compiling with SDK 34 and NDK 26b results in a working app, but only after I had to upgrade the AGP amongst a bunch of other stuff in Android Studio in order to build with the newer SDK/NDK, which to be honest is what probably made it work.

So I'm closing this.