Open OPunktSchmidt opened 4 years ago
Same problem : (
Same Problem Kindly fix
Same problem with android 11. Kindly update on this.
+1. My app also crashes with the exact same exception on Android 11. It's possible that the bug is in Android 11, I feel it's a bit of a buggy release, but still, it would be nice to have a work around or something. Thanks.
+1
Looks like someone has a potential fix: https://github.com/sfilmak/storage-chooser/commit/c43a6b534855da6b2e87fa0f25d0c67d40c84fbf
Has anyone found an alternative for this library? I don't think the bug will be fixed in the near future.
No need for an alternative. Someone else (sfilmak) fixed it. I forked his fork, tagged it and created a release for it. Since the original library uses jitpack, it's really easy to switch over to use your own fork of it. I just changed out:
com.github.codekidX:storage-chooser:2.0.4.4
and replaced it with:
com.github.mveroukis:storage-chooser:2.0.4.4a
The "a" at the end is my own tag, otherwise it would continue using the same version as the original. Now my app works in Android 11. As a bonus, it also uses newer versions of it's dependencies and targets API 30.
Good idea @mveroukis The commit https://github.com/sfilmak/storage-chooser/commit/c43a6b534855da6b2e87fa0f25d0c67d40c84fbf contains other changes that broke my build. I have forked and uploaded a commit with the only change that fixes the crash on Android 11 devices. Here's the my version:
https://github.com/NoelChew/storage-chooser/commit/f0ffc9ce5df35c9597eebc3b819093b74136e082
implementation 'com.github.noelchew:storage-chooser:2.0.4.4a'
I did manage to get the original code working with the external drive, a bit of a hack but its working ok for me.
I did step back for API 28 as there wasn't much point going to 29 or 30 due to scoped storage and this version of the app isnt going on google play so the api version doesnt matter.
If anyone is interested i can post the hack and maybe someone will improve upon it, it was a quick mod to the existing code.
Updated Dependencies, Optimised and compressed Resources and New Publishing Plugin
implementation("com.github.shabinder:storage-chooser:2.0.4.45")
FWIW I've also got a fork of this repo, with some additional fixes and changes
/storage
so I'm using getExternalFilesDirs)If anyone wants:
implementation 'com.github.mendhak:storage-chooser:2.0.4.4b'
Hi. @mendhak , i use your 'com.github.mendhak:storage-chooser:2.0.4.4b' and it's work good for open 'ChooserDialogFragment'. But if i use 'customFilter' or 'filter' in chooser builder, I have error at 'UniversalFileFilter.java' and 'SecondaryChooserFragment.java'.
code:
Content c = new Content();
c.setInternalStorageText(getString(R.string.DIALOG_STORAGE_TEXT));
c.setCancelLabel(getString(R.string.DIALOG_CANCEL));
c.setSelectLabel(getString(R.string.DIALOG_SELECT));
c.setOverviewHeading(getString(R.string.DIALOG_OVERVIEW_HEADING_IMPORT));
ArrayList<String> formats = new ArrayList<>();
formats.add("txt");
builder.withActivity(this)
.withFragmentManager(getFragmentManager())
.setMemoryBarHeight(1.5f)
.customFilter(formats)
.withContent(c)
.withMemoryBar(true)
.allowCustomPath(true)
.showHidden(true)
.hideFreeSpaceLabel(true)
.setType(StorageChooser.FILE_PICKER);
chooser = builder.build();
log: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:415) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923) Caused by: java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:220) at com.codekidlabs.storagechooser.filters.UniversalFileFilter.findInDirectory(UniversalFileFilter.java:98) at com.codekidlabs.storagechooser.filters.UniversalFileFilter.findInDirectory(UniversalFileFilter.java:121) at com.codekidlabs.storagechooser.filters.UniversalFileFilter.accept(UniversalFileFilter.java:53) at java.io.File.listFiles(File.java:1300) at com.codekidlabs.storagechooser.fragments.SecondaryChooserFragment$FileFilterTask.doInBackground(SecondaryChooserFragment.java:822) at com.codekidlabs.storagechooser.fragments.SecondaryChooserFragment$FileFilterTask.doInBackground(SecondaryChooserFragment.java:796) at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)
i try it on 'Android 11, Api30, Pixel 2(or3) ' in emulator and 'Android 11, Knox Api33, One UI3.1' in device
Maybe I'm doing something wrong( Can you help me please?
@kollabz this looks Android 11 related as well. dir.listFiles()
was returning null so this code block was throwing an exception.
I've added a check for length so it should be better now.
Do you want to try out the specific commit. If you say it's OK I could give it a tag.
implementation 'com.github.mendhak:storage-chooser:1715784d34'
@mendhak, i have no error with 'customFilter' or 'filter' in chooser builder, but i don't see any files in the selected directory. It's empy. ( Maybe something wrong with adapter? Can you help me with it please?
i try it on 'Android 11, Api30, Pixel 2(or3) ' in emulator and 'Android 11, Knox Api33, One UI3.1' in device. on 'Android 9, Api28 ' in device it work good
@kollabz two things I can think of. First is obviously you'll want to make sure there are some files that match the filter, obviously. Second is you'll need to make sure your app has permissions, see here. One thing I noticed, despite permissions, I couldn't filter anything under /emulated/0/Android/data
where all the app specific files are. I could play around at the top level like /emulated/0/Documents
.
Anyway I did a test I filtered to show just "csv" files and I was get this. You can see I copied your code minus the withActivity and withContent. I tried on Android 11 and 12.
This library seems to crash on Android 11. Is it planned to fix this? I dont get this error on other Android Versions