Dhaval2404 / ImagePicker

📸Image Picker for Android, Pick an image from Gallery or Capture a new image with Camera
Apache License 2.0
1.53k stars 341 forks source link

TransactionTooLargeException #232

Open klaszlo8207 opened 3 years ago

klaszlo8207 commented 3 years ago

I am getting this, when selected any image

java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 43091464 bytes at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:161) at android.os.Handler.handleCallback(Handler.java:900) at android.os.Handler.dispatchMessage(Handler.java:103) at android.os.Looper.loop(Looper.java:219) at android.app.ActivityThread.main(ActivityThread.java:8393) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055) Caused by: android.os.TransactionTooLargeException: data parcel size 43091464 bytes

android 10 Huawei Mate 20 pro

private fun getBase64Image() {
    ImagePicker.with(requireActivity())
        .compress(70)                        //70 KB
        .maxResultSize(512, 512)       //512*512 px
        .cropSquare()
        //.galleryOnly()
        .cameraOnly()
        .createIntent { intent ->
            startImageResult.launch(intent)
        }
}

implementation 'com.github.dhaval2404:imagepicker:2.1' implementation("com.github.florent37:inline-activity-result-kotlin:1.0.4") implementation "androidx.activity:activity-ktx:1.2.3" implementation "androidx.fragment:fragment-ktx:1.3.5"

klaszlo8207 commented 3 years ago

In the profiler my app is about 120-160 MB, when selected the ImagePicker and the camera photo take it increases to 280-300 MB, then crash! What is the solution?

hitesh-dhamshaniya commented 3 years ago

@klaszlo8207 Can you please try changing the resolution of the camera picture qualities. That might fix your issue temporary.

klaszlo8207 commented 3 years ago

@klaszlo8207 Can you please try changing the resolution of the camera picture qualities. That might fix your issue temporary.

Sorry I can't. In the profiler increased a lot of memory like I said.

I tried this lib too:

https://github.com/esafirm/android-image-picker

but the same probleme occured... So I ended up with this super library:

https://github.com/shaon2016/ProPicker

This is working like a charm!

This lib also better then the other two, because you can call it from anywhere, not just from fragments, and activities :)