nohana / Laevatein

Photo image selection activity set library. Currently under development.
247 stars 45 forks source link

NPE trying to use this library #23

Open forlayo opened 9 years ago

forlayo commented 9 years ago

I'm trying to use this library but I got a NPE when I execute the first try. I've used to try the next code snippet:

                        Laevatein.from(PresentationActivity.this)
                                .choose(MimeType.of(MimeType.JPEG))
                                .capture(true)
                                .forResult(9001);

And I got the following NPE:

01-18 19:42:50.887    1286-1286/com.bountycoon E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.bountycoon, PID: 1286
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bountycoon/com.laevatein.internal.ui.PhotoSelectionActivity}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2394)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2452)
            at android.app.ActivityThread.access$900(ActivityThread.java:172)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1302)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5586)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.laevatein.internal.ui.helper.PhotoSelectionActivityDrawerToggle.setUpActionBar(PhotoSelectionActivityDrawerToggle.java:57)
            at com.laevatein.internal.ui.PhotoSelectionActivity.onCreate(PhotoSelectionActivity.java:79)
            at android.app.Activity.performCreate(Activity.java:5451)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2452)
            at android.app.ActivityThread.access$900(ActivityThread.java:172)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1302)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5586)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
            at dalvik.system.NativeStart.main(Native Method)

P.S.:

I'm using latest toolbar and actionbar from Google support library ( because maybe it's related as I see on the NPE traces )

Nobodyhave commented 9 years ago

I've had the same problem. The reason is in using Toolbar. For using toolbar as action bar NoActionBar theme should be used. And this library uses support action bar in PhotoSelectionActivity. There is a detour for this collision. In your manifest insert this lines of code (you can use other AppCompat theme with action bar) <activity android:name="com.laevatein.internal.ui.PhotoSelectionActivity" android:theme="@style/Theme.AppCompat.Light"/>

<activity android:name="com.laevatein.internal.ui.ImagePreviewActivity" android:theme="@style/Theme.AppCompat.Light"/>

KeithYokoma commented 9 years ago

Yes, as @Nobodyhave says, using toolbar instead of action bar is the cause of this problem. We need some compatibility layer to deal with toolbar...

SagarRaiyani commented 9 years ago

Hello Nobodyhave,

I have tried your solution but it's not working for me please give me another suggestion for this example.

Thanks,

KeithYokoma commented 9 years ago

Good news guys, we've introduced toolbar into this library. You can get the update very soon.