question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Peer review NullPointerException on orientation change.

See original GitHub issue

Summary:

It crashes on orientation change on mis-category question.

System logs:

    --------- beginning of crash
2019-03-28 15:35:31.243 1986-1986/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: fr.free.nrw.commons.beta, PID: 1986
    java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.free.nrw.commons.beta/fr.free.nrw.commons.review.ReviewActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String fr.free.nrw.commons.media.model.MwQueryPage$Revision.getUser()' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4754)
        at android.app.ActivityThread.-wrap18(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1599)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6541)
        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)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String fr.free.nrw.commons.media.model.MwQueryPage$Revision.getUser()' on a null object reference
        at fr.free.nrw.commons.review.ReviewImageFragment.onCreateView(ReviewImageFragment.java:103)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2440)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:885)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1229)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1295)
        at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2605)
        at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2565)
        at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:245)
        at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:525)
        at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:179)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1333)
        at android.app.Activity.performStart(Activity.java:6992)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2780)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892) 
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4754) 
        at android.app.ActivityThread.-wrap18(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1599) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6541) 
        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) 

Device and Android version: API 26

Commons app version:

betaDebug, current master

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nfatmacommented, Jun 6, 2019

hi @ashishkumar468 , yes the problem is with the life cycle management. We can solve the issue by using the scopes in dagger as you suggested or by using onSaveInstanceState() also. I thought it would be nice if we can delegate work of UI controller with the help of ViewModel. As the app is not using it anywhere, we can add it later for more efficiency. 😃

1reaction
nicolas-raoulcommented, May 14, 2019

@nfatma Yes, it is yours now! Please let us know about your progress every few days. Thanks 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException when the orientation changes
I have a Preference activity where I get this error when it changes orientation: java.lang.NullPointerException: Attempt to invoke virtual ...
Read more >
ViewPager Null Pointer Exception when orientation changes ...
I first detected this issue when using JakeWharton ViewPager Library but believe the issue lies in the actually compatibility library.
Read more >
Null Pointer Exception on Screen Rotation · Issue #2 - GitHub
Hi ;). I notice an error while playing with your library. Nice work by the way ! To Reproduce, Just Launch "Top Fab...
Read more >
NullPointerException (Java Platform SE 8 ) - Oracle Help Center
Accessing or modifying the field of a null object. Taking the length of null as if it were an array. Accessing or modifying...
Read more >
Null Safety Tutorial in Kotlin: Best Practices - Kodeco
Getting Started; Finding a NullPointerException; Performing Null ... time or if you are recreating it, such as after an orientation change.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found