codekidX / storage-chooser

Lets user choose files in internal or external storage with just few lines of code.
Mozilla Public License 2.0
719 stars 153 forks source link

IndexOutOfBoundsException exception thrown #38

Open mveroukis opened 7 years ago

mveroukis commented 7 years ago

While testing it out in my app, I navigated to an internal storage folder, created a new folder and then attempted to navigate to that folder. At that moment it throws IndexOutOfBoundsException.

06-14 22:39:08.242 3521-3521/com.blitterhead.ampwifi E/AndroidRuntime: FATAL EXCEPTION: main Process: com.blitterhead.ampwifi, PID: 3521 java.lang.IndexOutOfBoundsException: Index: 1, Size: 0 at java.util.ArrayList.get(ArrayList.java:411) at com.codekidlabs.storagechooser.fragments.SecondaryChooserFragment$7$1.run(SecondaryChooserFragment.java:365) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

I built the storage chooser as follows: StorageChooser chooser = new StorageChooser.Builder() .withActivity(SettingsFragmentMisc.this.getActivity()) .withFragmentManager(getFragmentManager()) .withMemoryBar(true) .allowCustomPath(true) .allowAddFolder(true) .setType(StorageChooser.DIRECTORY_CHOOSER) .build();

I'm able to select folders fine as long as they are not created in that session. So when I re-ran the app and navigated back to where I created the new folder, I was able to select the new folder and everything worked fine. So, to be clear, the folder does get created fine, I just can't select it the first time through.

Here's how I added the dependency to storagechooser: compile 'com.github.codekidX:storage-chooser:1.0.35'

codekidX commented 7 years ago

Hi, Can you tell me

  1. what folder name have you added
  2. does it occur every time you create a folder

I just checked myself following same steps as you but no fc for me.

mveroukis commented 7 years ago

I don't know what to say. I did the above on the emulator and it did that consistently. I would create a new folder under internal storage, under Downloads (named the folder "Test"). Once the folder was created I'd select it and it would crash.

I just now tried it on a real device (Nexus 5X) and it worked fine. I restarted my emulator and it too now works. Strange. I'll play with it some more, but it looks like it might have been a peculiarity with my VM. I'll try it on some more real devices - I have a few kicking around. I'll get back to you.

brarcher commented 6 years ago

Although perhaps not much of a datapoint, I am seeing that on the Video Transcoder application a user from Google Play hit this failure on v2.0.3 here:

java.lang.IndexOutOfBoundsException: 
  at java.util.ArrayList.get (ArrayList.java:437)
  at com.codekidlabs.storagechooser.fragments.SecondaryChooserFragment$5$1.run (SecondaryChooserFragment.java:148)
  at android.os.Handler.handleCallback (Handler.java:789)
  at android.os.Handler.dispatchMessage (Handler.java:98)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6809)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:767)

Nothing else is know about the circumstance of the failure, so sorry no more details can be shared.

anisart commented 5 years ago

I have crash in Google Play console for version 2.0.4.4

Fatal Exception: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
       at java.util.ArrayList.get(ArrayList.java:437)
       at com.codekidlabs.storagechooser.fragments.SecondaryChooserFragment$5$1.run(SecondaryChooserFragment.java:27)
       at android.os.Handler.handleCallback(Handler.java:790)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6548)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)

Archos Core 57S Ultra - Android 8.1.0