Android Callback must not be null

android
login

#1

I have implemented Twitter login with Fabric plugin for Android Studio and it works.
Then I moved my code to a fragment and I got this:

> java.lang.IllegalArgumentException: Callback must not be null.
> at com.twitter.sdk.android.core.identity.TwitterAuthClient.authorize(TwitterAuthClient.java:95)
> at com.twitter.sdk.android.core.identity.TwitterLoginButton$LoginClickListener.onClick(TwitterLoginButton.java:161)
> at android.view.View.performClick(View.java:4759)
> at android.view.View$PerformClick.run(View.java:19770)
> at android.os.Handler.handleCallback(Handler.java:739)
> at android.os.Handler.dispatchMessage(Handler.java:95)
> at android.os.Looper.loop(Looper.java:135)
> at android.app.ActivityThread.main(ActivityThread.java:5234)
> 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:909)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)

I’m setting the callback in the onCreateView of the fragment, but on button click I got the null error.
I set
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Twitter(authConfig));

in to application class.