java.lang.NullPointerException: Attempt to read from field 'android.widget.ImageView com.ab.savr.activity.SetupActivity.SetupActivity2.CountrySpinnerAdapter$ViewHolder.countryFlag' on a null object reference

Stack Overflow | Ahmad | 3 months ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0

    java.lang.NullPointerException: Attempt to read from field 'android.widget.ImageView' on a null object reference in CursorAdapter

    Stack Overflow | 3 months ago | Ahmad
    java.lang.NullPointerException: Attempt to read from field 'android.widget.ImageView com.ab.savr.activity.SetupActivity.SetupActivity2.CountrySpinnerAdapter$ViewHolder.countryFlag' on a null object reference
  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

    spinner onItemSelected making issue

    Stack Overflow | 5 years ago | Muhamamd Awais
    java.lang.NullPointerException
  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 read from field 'android.widget.ImageView com.ab.savr.activity.SetupActivity.SetupActivity2.CountrySpinnerAdapter$ViewHolder.countryFlag' on a null object reference

      at com.ab.savr.activity.SetupActivity.SetupActivity2.CountrySpinnerAdapter.bindView()
    2. com.ab.savr
      CountrySpinnerAdapter.bindView
      1. com.ab.savr.activity.SetupActivity.SetupActivity2.CountrySpinnerAdapter.bindView(CountrySpinnerAdapter.java:63)
      1 frame
    3. Android Platform
      FrameLayout.onMeasure
      1. android.widget.CursorAdapter.getDropDownView(CursorAdapter.java:304)
      2. android.widget.Spinner$DropDownAdapter.getDropDownView(Spinner.java:963)
      3. android.widget.Spinner$DropDownAdapter.getView(Spinner.java:959)
      4. android.widget.AbsListView.obtainView(AbsListView.java:2346)
      5. android.widget.ListView.measureHeightOfChildren(ListView.java:1280)
      6. android.widget.ListView.onMeasure(ListView.java:1188)
      7. android.view.View.measure(View.java:18788)
      8. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
      9. android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
      10. android.view.View.measure(View.java:18788)
      11. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
      12. android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
      13. android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
      14. android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
      15. android.view.View.measure(View.java:18788)
      16. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
      17. android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
      18. android.view.View.measure(View.java:18788)
      19. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
      20. android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
      21. android.view.View.measure(View.java:18788)
      22. android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
      23. android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
      23 frames
    4. Android
      PhoneWindow$DecorView.onMeasure
      1. com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
      1 frame
    5. Android Platform
      ActivityThread.main
      1. android.view.View.measure(View.java:18788)
      2. android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
      3. android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1191)
      4. android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
      5. android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
      6. android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
      7. android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
      8. android.view.Choreographer.doCallbacks(Choreographer.java:670)
      9. android.view.Choreographer.doFrame(Choreographer.java:606)
      10. android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
      11. android.os.Handler.handleCallback(Handler.java:739)
      12. android.os.Handler.dispatchMessage(Handler.java:95)
      13. android.os.Looper.loop(Looper.java:148)
      14. android.app.ActivityThread.main(ActivityThread.java:5417)
      14 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:726)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
      2 frames