After updating compileSdkVersion and targetSdkVersion to 34 (Android 14), the application crashes when printing via USB using the ESCPOS-ThermalPrinter-Android library. The issue is related to the use of PendingIntent, which must be explicitly marked with FLAG_IMMUTABLE or FLAG_MUTABLE due to new security requirements in Android 14.
ERROR: java.lang.IllegalArgumentException: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.
After updating compileSdkVersion and targetSdkVersion to 34 (Android 14), the application crashes when printing via USB using the ESCPOS-ThermalPrinter-Android library. The issue is related to the use of PendingIntent, which must be explicitly marked with FLAG_IMMUTABLE or FLAG_MUTABLE due to new security requirements in Android 14.
ERROR: java.lang.IllegalArgumentException: Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.