I was using the usb_serial: ^0.5.1 package, and it was working perfectly fine. However, after upgrading my target SDK to 34 as per Google Play policy, the usb_serial package is now giving me exceptions. Any suggestions on how to resolve this issue?
E/UsbManager(28217): java.lang.SecurityException: User has not given 11132/com.example.serial_usb permission to access device /dev/bus/usb/002/002
E/UsbManager(28217): at android.os.Parcel.createExceptionOrNull(Parcel.java:3182)
E/UsbManager(28217): at android.os.Parcel.createException(Parcel.java:3166)
E/UsbManager(28217): at android.os.Parcel.readException(Parcel.java:3149)
E/UsbManager(28217): at android.os.Parcel.readException(Parcel.java:3091)
E/UsbManager(28217): at android.hardware.usb.IUsbManager$Stub$Proxy.openDevice(IUsbManager.java:1028) ```
Also the Popup for asking permission is not showing up now.
I tried switching back to targetSDk 33 and it is working fine
2
Answers
I discovered that the issue stems from the library, which does not yet support Android 14 on PubDev. Until the library is updated, you can use the following URL to address the problem:
in your pubspec.yaml file add this
usb_serial: git: url: https://github.com/altera2015/usbserial.git
usb_serial package is now updated on pub.dev to 0.5.2 which now supports android 14. you can now use it with targetAndroidSdk = 34.