Android SDK: IllegalStateException in OAuthActivity


#1

Hi there,

I’m using the Twitter Kit for Android to enable users to signin via Twitter in an app. It works fine and all the testing I have done are good, works as a charm.

But I have some crash report in Analytics:

	Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.[apppackagename]/com.twitter.sdk.android.core.identity.OAuthActivity}: java.lang.IllegalStateException: Must initialize Twitter before using getInstance()
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
	[...]

I did a quick search and:

  • In the fragment where I allow users to sign in, I use this:

      TwitterConfig config = new TwitterConfig.Builder(activity.getApplicationContext())
      	.logger(new DefaultLogger(Log.DEBUG))
      	.twitterAuthConfig(new TwitterAuthConfig("...", "..."))
      	.debug(true)
      	.build();
      Twitter.initialize(config);
    
      twitterAuthClient = new TwitterAuthClient();
    

(and so I call initialize before doing anything with the twitter auth client)

  • The crash is happening in the twitter-core-3.1.1 OAuthActivity class. And indeed, it seems that there’s no call to Twitter.initialize() here.

Is this a known issue? What can I do?

Thank you for your help,
Stéphane.


#2

No one? It looks like a bug in the twitter Android SDK, where can I report this?


#3

Twitter Kit for Android has a GitHub repository here ->


#4

Thank you!


#5

In case someone has the same problem and wants to follow the created issue on GitHub, here it is: https://github.com/twitter/twitter-kit-android/issues/105