java.lang.NullPointerException: Attempt to get length of null array

Stack Overflow | faisal1208 | 2 months ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to Rafael Fischer Viola and rafael . Or join the community to write better ones.
  1. 0
    samebug tip
    If you're using nested fragments, you have to use childFragmentManager instead of fragmentManager.
  2. 0
    samebug tip
    When you use findViewById inside an activity it is going to look for a View inside your main_activity.xml. If it's not there, it throws this exception, try to use the right view to call findviewById.
  3. 0

    Tabs not working properly when switching in android studio

    Stack Overflow | 2 months ago | faisal1208
    java.lang.NullPointerException: Attempt to get length of null array
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to get length of null array

      at com.example.accurat.faisal.helper.Utils.getFilePaths()
    2. com.example.accurat
      Pictures.onCreateView
      1. com.example.accurat.faisal.helper.Utils.getFilePaths(Utils.java:42)
      2. com.example.accurat.faisal.Pictures.onCreateView(Pictures.java:45)
      2 frames
    3. Android Support v4
      ViewPager.setCurrentItem
      1. android.support.v4.app.Fragment.performCreateView(Fragment.java:2184)
      2. android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1298)
      3. android.support.v4.app.FragmentManagerImpl.moveFragmentsToInvisible(FragmentManager.java:2323)
      4. android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2136)
      5. android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2092)
      6. android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1969)
      7. android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:620)
      8. android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
      9. android.support.v4.view.ViewPager.populate(ViewPager.java:1268)
      10. android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:668)
      11. android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:630)
      12. android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:611)
      12 frames
    4. android.support.design
      TabLayout$TabView.performClick
      1. android.support.design.widget.TabLayout$ViewPagerOnTabSelectedListener.onTabSelected(TabLayout.java:2178)
      2. android.support.design.widget.TabLayout.dispatchTabSelected(TabLayout.java:1155)
      3. android.support.design.widget.TabLayout.selectTab(TabLayout.java:1148)
      4. android.support.design.widget.TabLayout.selectTab(TabLayout.java:1118)
      5. android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1413)
      6. android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1523)
      6 frames
    5. Android Platform
      ActivityThread.main
      1. android.view.View$PerformClick.run(View.java:22596)
      2. android.os.Handler.handleCallback(Handler.java:739)
      3. android.os.Handler.dispatchMessage(Handler.java:95)
      4. android.os.Looper.loop(Looper.java:148)
      5. android.app.ActivityThread.main(ActivityThread.java:7325)
      5 frames
    6. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      1 frame
    7. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
      2 frames