nbsp-team / MaterialFilePicker

Picking files since 2015
Apache License 2.0
1.15k stars 229 forks source link

java.lang.NullPointerException: storage == null #27

Open MuhamedFathy opened 8 years ago

MuhamedFathy commented 8 years ago
java.lang.RuntimeException: Unable to start activity ComponentInfo{net.memozz.myapplication/com.nbsp.materialfilepicker.ui.FilePickerActivity}: java.lang.NullPointerException: storage == null
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                          at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:134)
                                                                       Caused by: java.lang.NullPointerException: storage == null
                                                                          at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
                                                                          at java.util.Arrays.asList(Arrays.java:155)
                                                                          at com.nbsp.materialfilepicker.utils.FileUtils.getFileListByDirPath(FileUtils.java:16)
                                                                          at com.nbsp.materialfilepicker.ui.DirectoryFragment.initFilesList(DirectoryFragment.java:84)
                                                                          at com.nbsp.materialfilepicker.ui.DirectoryFragment.onViewCreated(DirectoryFragment.java:79)
                                                                          at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:988)
                                                                          at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
                                                                          at android.app.BackStackRecord.run(BackStackRecord.java:793)
                                                                          at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
                                                                          at android.app.FragmentController.execPendingActions(FragmentController.java:325)
                                                                          at android.app.Activity.performStart(Activity.java:6267)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                          at android.os.Looper.loop(Looper.java:148) 
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                          at java.lang.reflect.Method.invoke(Native Method) 
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
                                                                          at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:134) 
heatherSnepenger commented 8 years ago

The problem is that you haven't requested permission for Android version 6+ https://github.com/nbsp-team/MaterialFilePicker/issues/13

alensiljak commented 8 years ago

I'm getting these also on Android 4.2 so it can't be just the Android 6+ permissions.

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.money.manager.ex/com.nbsp.materialfilepicker.ui.FilePickerActivity}: java.lang.NullPointerException: storage == null
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
       at android.app.ActivityThread.access$1100(ActivityThread.java:221)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:158)
       at android.app.ActivityThread.main(ActivityThread.java:7225)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by java.lang.NullPointerException: storage == null
       at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
       at java.util.Arrays.asList(Arrays.java:155)
       at com.nbsp.materialfilepicker.utils.FileUtils.getFileListByDirPath(FileUtils.java:16)
       at com.nbsp.materialfilepicker.ui.DirectoryFragment.initFilesList(DirectoryFragment.java:84)
       at com.nbsp.materialfilepicker.ui.DirectoryFragment.onViewCreated(DirectoryFragment.java:79)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:998)
       at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1163)
       at android.app.BackStackRecord.run(BackStackRecord.java:793)
       at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1552)
       at android.app.FragmentController.execPendingActions(FragmentController.java:325)
       at android.app.Activity.performStart(Activity.java:6914)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3216)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
       at android.app.ActivityThread.access$1100(ActivityThread.java:221)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:158)
       at android.app.ActivityThread.main(ActivityThread.java:7225)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
ddudek commented 7 years ago

The issue is not with android M or any other. I was able to recreate it today on Samsung J5 Android 5.1.1, but in my crashlogs from production this exact stactrace is visible also on 4.2.2.

Would be nice to add error handling when listing directory returns "null" due to no access

Easy steps to reproduce: Environment: stock Samsung J5, android 5.1.1

  1. use root "/" for start directory, example: Intent filePickerIntent = new Intent(context, FilePickerActivity.class); filePickerIntent.putExtra(FilePickerActivity.ARG_START_PATH, "/");
  2. navigate to some directory with no access, for me this was for example "/cache", "/confg"
  3. crash occurs:
    
                  Process: com.jobartis.staging, PID: 18417
                  java.lang.NullPointerException: storage == null
                      at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
                      at java.util.Arrays.asList(Arrays.java:155)
                      at com.nbsp.materialfilepicker.utils.FileUtils.getFileListByDirPath(FileUtils.java:16)
                      at com.nbsp.materialfilepicker.ui.DirectoryFragment.initFilesList(DirectoryFragment.java:84)
                      at com.nbsp.materialfilepicker.ui.DirectoryFragment.onViewCreated(DirectoryFragment.java:79)
                      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
                      at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
                      at android.app.BackStackRecord.run(BackStackRecord.java:834)
                      at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1470)
                      at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
                      at android.os.Handler.handleCallback(Handler.java:739)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:145)
                      at android.app.ActivityThread.main(ActivityThread.java:6934)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:372)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)```