HBiSoft / PickiT

An Android library that returns real paths from Uri's

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash for some images

selankon opened this issue · comments

Describe the bug

After upgrading to PickIt 2.0.3 we implemented the method pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT). For some images, the program crash unexpectedly.

Describe the bug

We have this line where it crash:

if(pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT)  || !pickiT.wasLocalFileSelected(uri)) {
        result.error("IS_REMOTE_FILE", "The selected file is remote and is not implemented yet", null);
      }

And for this file content://com.android.providers.media.documents/document/image%3A66 the program crash.
But NOT for this content://com.android.providers.media.documents/document/image%3A65

Both are local (I can see them without internet connection). And if I disable the pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT) it still crashing. Neither downgrading to previous pickit version.

We also upgraded sdk from 30 to 31.

Log

E/AndroidRuntime(29424): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(29424): Process: net.altermundi.elrepoio, PID: 29424
E/AndroidRuntime(29424): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime(29424): 	at android.os.AsyncTask$4.done(AsyncTask.java:399)
E/AndroidRuntime(29424): 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime(29424): 	at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime(29424): 	at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime(29424): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
E/AndroidRuntime(29424): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(29424): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(29424): 	at java.lang.Thread.run(Thread.java:919)
E/AndroidRuntime(29424): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference
E/AndroidRuntime(29424): 	at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:71)
E/AndroidRuntime(29424): 	at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:19)
E/AndroidRuntime(29424): 	at android.os.AsyncTask$3.call(AsyncTask.java:378)
E/AndroidRuntime(29424): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime(29424): 	... 4 more
I/Process (29424): Sending signal. PID: 29424 SIG: 9

PickiT version

2.0.3

Device information

  • Make/model

Redmi 9A MIUI 12.0.9

  • SDK version
 compileSdkVersion 31
minSdkVersion 16
commented

This issue has been automatically marked as stale because it has not had activity in the last 14 days. It will be closed if no further activity occurs within the next 3 days. Thank you for your contributions.

Hi!

Any ideas where to search with that? I'm not very habituated to Android

It seems like your Activity is null.

Did you call pickiT = new PickiT(this, this, this); before calling pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT) || !pickiT.wasLocalFileSelected(uri)?


The crash is happening in DownloadAsyncTask and it should not happen when you are only calling the above because isUnknownProvider is not calling DownloadAsyncTask.

Please provide your Activity where you are using PickiT so I'm able to see how you have implemented it.

Hi, sorry for the late answer:

I'm trying to use PickiT on a flutter plugin. The code is here https://gitlab.com/elRepo.io/flutter_absolute_path/, where relevant parts are:

I can't understand why is happening for some photos and for others no! All the times the same photos are causing error, and the photos that work, work all the times. So it seem related to the file.

Is like pickit thinks that is a remote image for some reason and try to do the DownloadAsyncTask?

E/AndroidRuntime(17798): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(17798): Process: net.altermundi.flutter_absolute_path_example, PID: 17798
E/AndroidRuntime(17798): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime(17798): 	at android.os.AsyncTask$4.done(AsyncTask.java:415)
E/AndroidRuntime(17798): 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime(17798): 	at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime(17798): 	at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime(17798): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
E/AndroidRuntime(17798): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(17798): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(17798): 	at java.lang.Thread.run(Thread.java:923)
E/AndroidRuntime(17798): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference
E/AndroidRuntime(17798): 	at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:71)
E/AndroidRuntime(17798): 	at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:19)
E/AndroidRuntime(17798): 	at android.os.AsyncTask$3.call(AsyncTask.java:394)
E/AndroidRuntime(17798): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime(17798): 	... 4 more
I/Process (17798): Sending signal. PID: 17798 SIG: 9

Please reopen the issue again

Where exactly are you selecting the file from? Are you using Android's default file picker or a third party application, like "File Manager"?

Thanks for the fast answer.

I'm not sure, I'm using a flutter file picker plugin which seem to call the default file picker, but not pretty sure. On this function it build the intent to finally open the file picker using:

if (intent.resolveActivity(this.activity.getPackageManager()) != null) {
            this.activity.startActivityForResult(intent, REQUEST_CODE);
        } 

Then, it return to me the URI of the file, and I pass this string to PickiT lib to try to get the absolute path. Which sometimes fail for some specific images.

Please try the following and get back to me...

Remove line 64-70 in your project :

String uriString = (String) call.argument("uri");
Uri uri = Uri.parse(uriString);
if(pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT)  || !pickiT.wasLocalFileSelected(uri)) {
    result.error("IS_REMOTE_FILE", "The selected file is remote and is not implemented yet", null);
}
this._result = result;
pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT);

and add the following:

Uri uri = call.argument("uri");
if(pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT)  || !pickiT.wasLocalFileSelected(uri)) {
    result.error("IS_REMOTE_FILE", "The selected file is remote and is not implemented yet", null);
}
this._result = result;

Then run your application and let me know if it is still crashing.

Without pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT); at the end? Anyway, trying both, I receive a:

java.lang.ClassCastException: java.lang.String cannot be cast to android.net.Uri

This is because call.argument("uri"); is a parameter passed from Flutter code and is a String, not an Object. You can pass data from Dart to Native platforms and viceversa using this method

Ok just remove pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT); and keep the rest as it was

Ok, here the behavior for "non crashing files" is no string returned (it never arrive here).

For the "crshing file" the result is a string that say Remote file. And I'm pretty sure is not a remote file.

Can you please confirm if you tested removing pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT);?

Does it crash or not, what happens???

if (call.method.equals("getAbsolutePath")) {
      String uriString = (String) call.argument("uri");
      Uri uri = Uri.parse(uriString);
      if(pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT)  || !pickiT.wasLocalFileSelected(uri)) {
        result.error("IS_REMOTE_FILE", "The selected file is remote and is not implemented yet", null);
      }
      this._result = result;
//      pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT);
    } else {
      result.notImplemented();
    }

This causes no crash, but neither return the absolute path for the "no-crashing" files, and for the "crashing" files return the string Remote file.

For some reason PickiT thought that is a remote file

The only logical conclusion I have is that the library (flutter_file_picker) you are using is setting the intent to the following when selecting images:

if (type.equals("image/*")) {
    intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
}

and not adding the following action when selecting images (Only when its not images):

intent.setAction(Intent.ACTION_GET_CONTENT); 

You can see this here


Look at my demo application, I set the intent to the following:

Intent intent;
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
} else {
intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.INTERNAL_CONTENT_URI);
}
// In this example we will set the type to video
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra("return-data", true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
activityResultLauncher.launch(intent);

If I was to select images I would change the above to the following:

Intent intent; 
 if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { 
     intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 
 } else { 
     intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI); 
 } 
 //  In this example we will set the type to video 
 intent.setType("image/*"); 
 intent.setAction(Intent.ACTION_GET_CONTENT); 
 intent.putExtra("return-data", true); 
 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { 
     intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); 
 } 
 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
 activityResultLauncher.launch(intent); 

Have a look at this answer on stackoverflow.


I'm not able to reproduce it on my device. The only suggestion I have is to run the demo application on your device and if it doesn't crash then the issue is not related to PickiT. If the demo application doesn't crash then you have 2 options, either ask the developer of flutter_file_picker to set intent.setAction(Intent.ACTION_GET_CONTENT); for all files, or you can change it yourself but then you will have to build the project yourself.

Unfortunately, there is nothing I can do about this from my side.

Hi thanks for the answer. Could be possible that with the compiled demo example apk I can only select videos?

I will change it so you can select images instead. I will let you know when it's updated.

I've updated it, you can download the updated demo application here. Let me know what happens when you select the file that's causing the crash.

Ok, no crash. But:

For the images that causes a crash, PickiT copy it to a temp file. I send you the PickiT log obtained doing: adb logcat | grep --ignore-case -i "pickit". So a temporary solution for me is to implement a temporary copy of the image as you do in the demo. Here the log:

04-28 16:05:00.492   583  1314 I BufferQueueProducer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#0](this:0xe638c000,id:2017,api:1,p:32255,c:583) queueBuffer: fps=0.40 dur=2519.16 max=2519.16 min=2519.16
04-28 16:05:00.552  1191  5809 D PowerHalWrapper: <amsBoostResume> last:com.hbisoft.pickitexample, next:com.google.android.documentsui 
04-28 16:05:00.571   553   591 I powerd  : [powerd_req] POWER_MSG_NOTIFY_STATE, pc:0, com.hbisoft.pickitexample => com.google.android.documentsui
04-28 16:05:01.334   583   623 I BufferQueueProducer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#0](this:0xe638c000,id:2017,api:1,p:32255,c:583) disconnect(P): api 1
04-28 16:05:01.379   583   583 I BufferQueue: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#0](this:0xe638c000,id:2017,api:1,p:-1,c:-1) ~BufferQueueCore
04-28 16:05:01.496  1191  5809 W NotificationService: Toast already killed. pkg=com.hbisoft.pickitexample callback=android.app.ITransientNotification$Stub$Proxy@d3e6566
04-28 16:05:02.549  1191  5809 D PowerHalWrapper: <amsBoostResume> last:com.google.android.documentsui, next:com.hbisoft.pickitexample 
04-28 16:05:02.560  1191  2290 D PowerHalWrapper: amsBoostNotify pid:32255,activity:com.hbisoft.pickitexample.MainActivity, package:com.hbisoft.pickitexample, mProcessCreatePacknet.altermundi.elrepoio 
04-28 16:05:02.561   553   591 I libPowerHal: [perfNotifyAppState] foreground:com.hbisoft.pickitexample, pid:32255, uid:10364
04-28 16:05:02.562   553   591 I UxUtility: notifyForegroundApp pack:com.hbisoft.pickitexample, uid:10364
04-28 16:05:02.562   553   591 I powerd  : [powerd_req] POWER_MSG_NOTIFY_STATE, pc:0, com.google.android.documentsui => com.hbisoft.pickitexample
04-28 16:05:02.618  1191  2637 I WindowManager: Relayout Window{9ca384a u0 com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity}: oldVis=4 newVis=0 focusMayChange = true
04-28 16:05:02.619   583  2025 I BufferQueueConsumer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#0](this:0xe8f5f000,id:2020,api:0,p:-1,c:583) setConsumerName: com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#0
04-28 16:05:02.620   583  2025 I BufferQueueConsumer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#0](this:0xe8f5f000,id:2020,api:0,p:-1,c:583) setDefaultBufferSize: width=720 height=1600
04-28 16:05:02.627   583   623 I BufferQueueProducer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#0](this:0xe8f5f000,id:2020,api:1,p:32255,c:583) connect(P): api=1 producer=(32255:com.hbisoft.pickitexample) producerControlledByApp=false
04-28 16:05:02.643   583   623 I BufferQueueConsumer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#1](this:0xe8fd4000,id:2021,api:0,p:-1,c:583) setConsumerName: com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#1
04-28 16:05:02.643   583   623 I BufferQueueConsumer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#1](this:0xe8fd4000,id:2021,api:0,p:-1,c:583) setDefaultBufferSize: width=129 height=129
04-28 16:05:02.647   583   623 I BufferQueueConsumer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#1](this:0xe8fd4000,id:2021,api:0,p:-1,c:583) setDefaultBufferSize: width=812 height=360
04-28 16:05:02.656   583  1314 I BufferQueueProducer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#1](this:0xe8fd4000,id:2021,api:1,p:32255,c:583) connect(P): api=1 producer=(32255:com.hbisoft.pickitexample) producerControlledByApp=false
04-28 16:05:02.678   583  1314 I BufferQueueProducer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#1](this:0xe8fd4000,id:2021,api:1,p:32255,c:583) disconnect(P): api 1
04-28 16:05:02.699  1191  1293 E InputDispatcher: Window handle Window{ded66c0 u0 com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity} has no registered input channel
04-28 16:05:02.702 32255 32255 D ForceDarkHelper: updateByCheckExcludeList: pkg: com.hbisoft.pickitexample activity: com.hbisoft.pickitexample.MainActivity@fe718a3
04-28 16:05:02.703 32255 32255 I chatty  : uid=10364(com.hbisoft.pickitexample) identical 3 lines
04-28 16:05:02.705 32255 32255 D ForceDarkHelper: updateByCheckExcludeList: pkg: com.hbisoft.pickitexample activity: com.hbisoft.pickitexample.MainActivity@fe718a3
04-28 16:05:02.782   583  2025 I BufferQueueConsumer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#2](this:0xe4e94000,id:2022,api:0,p:-1,c:583) setConsumerName: com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#2
04-28 16:05:02.782   583  2025 I BufferQueueConsumer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#2](this:0xe4e94000,id:2022,api:0,p:-1,c:583) setDefaultBufferSize: width=129 height=129
04-28 16:05:02.787   583  2025 I BufferQueueConsumer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#2](this:0xe4e94000,id:2022,api:0,p:-1,c:583) setDefaultBufferSize: width=812 height=379
04-28 16:05:02.795   583  2025 I BufferQueueProducer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#2](this:0xe4e94000,id:2022,api:1,p:32255,c:583) connect(P): api=1 producer=(32255:com.hbisoft.pickitexample) producerControlledByApp=false
04-28 16:05:02.881   583   583 I BufferQueue: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#1](this:0xe8fd4000,id:2021,api:1,p:-1,c:-1) ~BufferQueueCore
04-28 16:05:03.082   583  1522 I BufferQueueProducer: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#2](this:0xe4e94000,id:2022,api:1,p:32255,c:583) disconnect(P): api 1
04-28 16:05:03.096  1191  2290 E InputDispatcher: Window handle Window{2052b1c u0 com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity} has no registered input channel
04-28 16:05:03.111  5217  5217 I GoogleInputMethodService: GoogleInputMethodService.onStartInput():1907 onStartInput(EditorInfo{inputType=0x0(NULL) imeOptions=0x0 privateImeOptions=null actionName=UNSPECIFIED actionLabel=null actionId=0 initialSelStart=-1 initialSelEnd=-1 initialCapsMode=0x0 hintText=null label=null packageName=com.hbisoft.pickitexample fieldId=-1 fieldName=null extras=null}, false)
04-28 16:05:03.118 32255 32255 I Toast   : Show toast from OpPackageName:com.hbisoft.pickitexample, PackageName:com.hbisoft.pickitexample
04-28 16:05:03.141   583  2025 I BufferQueueProducer: [Toast#0](this:0xe8fd4000,id:2023,api:1,p:32255,c:583) connect(P): api=1 producer=(32255:com.hbisoft.pickitexample) producerControlledByApp=false
04-28 16:05:03.272  1191  1226 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{e4f53f4 u0 com.hbisoft.pickitexample/.MainActivity t1956} time:367456161
04-28 16:05:03.278   583   583 I BufferQueue: [com.hbisoft.pickitexample/com.hbisoft.pickitexample.MainActivity#2](this:0xe4e94000,id:2022,api:1,p:-1,c:-1) ~BufferQueueCore
04-28 16:05:06.675  1191  2847 W NotificationService: Toast already killed. pkg=com.hbisoft.pickitexample callback=android.app.ITransientNotification$Stub$Proxy@e082a14

Is really strange, why this images are treated as "network" files?!

After some testing, I found the reason why this is happening. I will fix it and let you know once I have updated the library.

This is fixed in 2.0.5. You can test the demo application, it should now return the path instead of unnecessarily copying the file to the temp folder. Please let me know after you have tested.

Thx I test it ASAP

Yep now it works now, thank you so much! :D

You're welcome. Thanks for reporting it.

Seem is still crashing on the flutter "portability" with exactly the same behavior described above. I have to change something on the implementation?

I just upgraded to PickiT 2.0.5 on my Gradle but nothing seems to change! I have to do something else?

(I tried cleaning caches, deleting generated code, uninstalling and it seem still working on previous version)

Can you please send me a recording of this? The entire process, from opening the application until the crash occurs.

Hi,

Ok. First I updated all references of the PickiT library on all build.gradle:

dependencies {
    implementation 'com.github.HBiSoft:PickiT:2.0.5'
}

This simple action should upgrade the library right? I suspect this didn't work as expected...

And then, my code didn't change. With this code:

  @Override
  public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
    if (call.method.equals("getAbsolutePath")) {
      String uriString = (String) call.argument("uri");
      Uri uri = Uri.parse(uriString);
      if(pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT)  || !pickiT.wasLocalFileSelected(uri)) {
        result.error("IS_REMOTE_FILE", "The selected file is remote and is not implemented yet", null);
      }
      this._result = result;
      pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT);
    } else {
      result.notImplemented();
    }
  }

With this, I got same error as with PickiT 2.0.3 (for "crashing images only"):

W/Glide   (21482): Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored
D/CompatibilityChangeReporter(21482): Compat change id reported: 149924527; UID 10262; state: ENABLED
D/CompatibilityChangeReporter(21482): Compat change id reported: 149924527; UID 10262; state: ENABLED
D/CompatibilityChangeReporter(21482): Compat change id reported: 149924527; UID 10262; state: ENABLED
D/CompatibilityChangeReporter(21482): Compat change id reported: 132649864; UID 10262; state: DISABLED
D/ExifInterface(21482): No image meets the size requirements of a thumbnail image.
E/RecyclerView(21482): No adapter attached; skipping layout
E/AndroidRuntime(21482): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(21482): Process: net.altermundi.flutter_absolute_path_example, PID: 21482
E/AndroidRuntime(21482): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime(21482): 	at android.os.AsyncTask$4.done(AsyncTask.java:415)
E/AndroidRuntime(21482): 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime(21482): 	at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime(21482): 	at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime(21482): 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
E/AndroidRuntime(21482): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(21482): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(21482): 	at java.lang.Thread.run(Thread.java:923)
E/AndroidRuntime(21482): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference
E/AndroidRuntime(21482): 	at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:71)
E/AndroidRuntime(21482): 	at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:19)
E/AndroidRuntime(21482): 	at android.os.AsyncTask$3.call(AsyncTask.java:394)
E/AndroidRuntime(21482): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime(21482): 	... 4 more
I/Process (21482): Sending signal. PID: 21482 SIG: 9
Lost connection to device.
Failed to send request: {"jsonrpc":"2.0","id":"31","method":"getMemoryUsage","params":{"isolateId":"isolates/1327121224649123"}}

Probably is a problem of how I manage the activity from the Flutter plugin.

As well, for "crashing images" only, if I comment following line:

...
      }
      this._result = result;
      // pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT);
    } else {
...

Resulting string is Remote file, and I can't get the "non crashing images" paths.

I suspect is a library upgrading problem... But I guess I did all local steps properly (cleaning caches, uninstalling, etc...). Could be a repository problem?

Can you please send me a recording of this? The entire process, from opening the application until the crash occurs.

Without this, I can't help you.

You can download the demo application of my screen recording library here, or you can download a screen recording app and send me the video of the entire process. From the moment you open your application until it crashes.

Ah, you meaning screen recording?

I didn't saw the video doesn't upload properly. Trying again using 'com.github.HBiSoft:PickiT:2.0.5' on gradle:

Using pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT)

Using this code.

The program simply crashes due the Activity error:

E/AndroidRuntime(17798): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(17798): Process: net.altermundi.flutter_absolute_path_example, PID: 17798
E/AndroidRuntime(17798): java.lang.RuntimeException: An error occurred while executing doInBackground()

output2

Without pickiT.getPath

As you suggested, I tried also commenting the line:

// pickiT.getPath(uri, android.os.Build.VERSION.SDK_INT);

Here it return just the Remote file string:

output

Is possible that library is not updated properly on Gradle? The behavior is exactly same as previous version 2.0.3, and not as the demo application

Like I said previously, this is not related to the library itself.

There are a lot of things that can cause this, for example; Have a look at my demo application, I use ClipData to check if multiple files were selected. I have found previously that if you do not use ClipData to check if multiple files are selected, it causes issues on some devices. EVEN IF YOU ONLY SELECT ONE FILE.

ClipData clipData = Objects.requireNonNull(data).getClipData();
if (clipData != null) {
int numberOfFilesSelected = clipData.getItemCount();
if (numberOfFilesSelected > 1) {
pickiT.getMultiplePaths(clipData);
StringBuilder allPaths = new StringBuilder("Multiple Files Selected:" + "\n");
for(int i = 0; i < clipData.getItemCount(); i++) {
allPaths.append("\n\n").append(clipData.getItemAt(i).getUri());
}
originalTv.setText(allPaths.toString());
}else {
pickiT.getPath(clipData.getItemAt(0).getUri(), Build.VERSION.SDK_INT);
originalTv.setText(String.valueOf(clipData.getItemAt(0).getUri()));
}
} else {
pickiT.getPath(data.getData(), Build.VERSION.SDK_INT);
originalTv.setText(String.valueOf(data.getData()));
}

The fact that the demo application returns the correct path means that this is not related to the library.

Ok I will double check this. Thanks again

Hi,

After fork my own implementation for the Flutter file dialog, I'm developing a working example that gets absolute file path using PickiT from a Flutter plugin.

See this MR to see the changes https://gitlab.com/elRepo.io/flutter_file_dialog_pickit/-/merge_requests/1

@selankon So it is working now?

Yes, thanks. As you said, using ClipData fixed the problem

Great. I'm glad you were able to get it working. Let me know when there is anything else I can help you with.

Yes! Thanks for support! (and for the library, I'm surprised of how difficult is to get an Absolute path on Android devices...)