Upgrade gradle, NDK version, target version, fix permission issues
Following changes to make it compile and run under latest Android Studio:
- Upgrade gradle scripts
- Update obsolete dependencies (only those that was breaking build)
- Update NDK version
- Update min/target SDK version
- Replace jcenter with mavenCentral
- Single place to change NDK version
- Single place to change min/target SDK version
- Upgrade Gradle plugin version
- Upgrade Kotlin version
- Upgrade Gradle version
- Upgrade CMake version
- Remove obsolete build tools version
- Remove useDeprecatedNdk flag
- Fix native code to compile with new NDK
- Fixed ACTION_USB_PERMISSION intent to use FLAG_MUTABLE on newer Android
- Tried to update x86 targets, but it require updating native libraries with PIC support, so removed x86 for now
@ernestp were you able to get the app connected to modern usb cameras? I got your updated code to compile and run with the latest Android Studio, but my camera, which I got from Amazon, is not detected.
@w3ichen It work with my camera, but I need to restart the app after install and first run. If your camera is working with apk from https://github.com/jiangdongguo/AndroidUSBCamera/tree/master then it should work with this pull request. However issue comes from increasing target SDK version. Try to set target SDK version to 27 as in original repo and check if that is fixes issue for you.
@ernestp thanks. I'm using your branch with target SDK set to 27. It seems to recognize the camera, but it has 2 issues: no videofeed/preview is showing (just blank screen), and when I click the shutter button, I get an error about unable to write to storage. Have you faced this issues before? I'm running this on Samsung Galaxy with Android 14, and tried two usb webcams that I plugged in via a usb-A to usb-C dongle.
Thanks for your help!
@w3ichen I prepared another PR - https://github.com/jiangdongguo/AndroidUSBCamera/pull/736 and will merge both to my fork. And I guess I will go with the next changes in my own repo as original repo don't seems to be active.
@ernestp good job have you ever met OOM like this?
09-01 04:00:56.950 1113 979 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: binder:1113_13 09-01 04:00:56.950 1113 979 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 56 byte allocation with 5275168 free bytes and 5151KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC. 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.nativeReadString16(Native Method) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.readString16NoHelper(Parcel.java:3097) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel$ReadWriteHelper.readString16(Parcel.java:497) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.readString16(Parcel.java:3076) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.readString(Parcel.java:3066) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.readParcelableCreatorInternal(Parcel.java:4836) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.readParcelableInternal(Parcel.java:4766) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.readParcelableArrayInternal(Parcel.java:4965) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.readParcelableArray(Parcel.java:4952) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.hardware.usb.UsbDevice$1.createFromParcel(UsbDevice.java:361) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.hardware.usb.UsbDevice$1.createFromParcel(UsbDevice.java:348) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Parcel.readTypedObject(Parcel.java:3947) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.hardware.usb.IUsbManager$Stub.onTransact(IUsbManager.java:591) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Binder.execTransactInternal(Binder.java:1280) 09-01 04:00:56.950 1113 979 E AndroidRuntime: at android.os.Binder.execTransact(Binder.java:1244) 09-01 04:01:05.377 1113 979 E AndroidRuntime: OutOfMemoryError IN SYSTEM PROCESS: Already dump hprof! 09-01 04:01:05.377 1113 979 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 56 byte allocation with 5275168 free bytes and 5151KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC. 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.nativeReadString16(Native Method) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.readString16NoHelper(Parcel.java:3097) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel$ReadWriteHelper.readString16(Parcel.java:497) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.readString16(Parcel.java:3076) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.readString(Parcel.java:3066) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.readParcelableCreatorInternal(Parcel.java:4836) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.readParcelableInternal(Parcel.java:4766) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.readParcelableArrayInternal(Parcel.java:4965) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.readParcelableArray(Parcel.java:4952) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.hardware.usb.UsbDevice$1.createFromParcel(UsbDevice.java:361) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.hardware.usb.UsbDevice$1.createFromParcel(UsbDevice.java:348) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Parcel.readTypedObject(Parcel.java:3947) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.hardware.usb.IUsbManager$Stub.onTransact(IUsbManager.java:591) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Binder.execTransactInternal(Binder.java:1280) 09-01 04:01:05.377 1113 979 E AndroidRuntime: at android.os.Binder.execTransact(Binder.java:1244) 09-01 04:01:05.377 1113 1113 W Looper : Slow delivery took 4466ms main h=android.os.Handler c=com.android.internal.os.BinderCallsStats$1@825bfb2 m=0 09-01 04:01:05.379 1113 979 I DropBoxManagerService: add tag=system_server_crash isTagEnabled=true flags=0x2 09-01 04:01:05.380 1113 1113 W Looper : Drained 09-01 04:01:05.380 1113 1210 E PackageManager: Missing permissions state for com.android.systemui and user -1 09-01 04:01:10.889 32391 32452 E AndroidRuntime: FATAL EXCEPTION: USBMonitor