Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

NPE trying to use this library #23

Open
forlayo opened this issue Jan 18, 2015 · 4 comments
Open

NPE trying to use this library #23

forlayo opened this issue Jan 18, 2015 · 4 comments

Comments

@forlayo
Copy link

forlayo commented Jan 18, 2015

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
Copy link

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
Copy link
Contributor

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
Copy link

Hello Nobodyhave,

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

Thanks,

@KeithYokoma
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants