bluelinelabs / Conductor

A small, yet full-featured framework that allows building View-based Android applications
Apache License 2.0
3.9k stars 343 forks source link

NPE when I picked a image #12

Closed baoti closed 8 years ago

baoti commented 8 years ago

When I touched "Target Controller", "PICK IMAGE (FROM GALLERY)", and picked a image, then the demo app crashed.

 Process: com.bluelinelabs.conductor.demo, PID: 5946
 java.lang.RuntimeException: Failure delivering result ResultInfo{who=android:fragment:0, request=126, result=-1, data=Intent { dat=content://media/external/images/media/27659 }} to activity {com.bluelinelabs.conductor.demo/com.bluelinelabs.conductor.demo.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageURI(android.net.Uri)' on a null object reference
     at android.app.ActivityThread.deliverResults(ActivityThread.java:3542)
     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3585)
     at android.app.ActivityThread.access$1300(ActivityThread.java:147)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332)
     at android.os.Handler.dispatchMessage(Handler.java:102)
     at android.os.Looper.loop(Looper.java:135)
     at android.app.ActivityThread.main(ActivityThread.java:5237)
     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:906)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:701)
  Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageURI(android.net.Uri)' on a null object reference
     at com.bluelinelabs.conductor.demo.controllers.TargetDisplayController.setImageView(TargetDisplayController.java:98)
     at com.bluelinelabs.conductor.demo.controllers.TargetDisplayController.onActivityResult(TargetDisplayController.java:68)
     at com.bluelinelabs.conductor.Router.onActivityResult(Router.java:52)
     at com.bluelinelabs.conductor.internal.LifecycleHandler.onActivityResult(LifecycleHandler.java:130)
     at android.app.Activity.dispatchActivityResult(Activity.java:6145)
     at android.app.ActivityThread.deliverResults(ActivityThread.java:3538)
     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3585) 
     at android.app.ActivityThread.access$1300(ActivityThread.java:147) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1332) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:135) 
     at android.app.ActivityThread.main(ActivityThread.java:5237) 
     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:906) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:701) 

Device: Xiaomi2(MI 2S), Android 5.0.2 LRX22G.

EricKuck commented 8 years ago

This is an issue caused by the latest version I'm looking into it now and should have a fix tomorrow morning. Sorry about that!

cs-victor-nascimento commented 8 years ago

Just if anyone needs a workaround meanwhile, use:

setRetainViewMode(RetainViewMode.RETAIN_DETACH);
EricKuck commented 8 years ago

It actually ended up being easier to fix than expected. A new version (1.1.1) is being uploaded to bintray/maven central now and should be available in the next few minutes. Feel free to re-open if you notice any other 1.1.x weirdness.