Whitelisted but gets Post Tweet Failed on Android only

android
fabric
oauth

#1

Hello!

I’m using Unity + Fabric, got an email saying my app’s now whitelisted, and it works on iOS! The problem now is that it’s not working on Android, giving me these two error logs:

E/Parcel ( 814): Class not found when unmarshalling: com.twitter.sdk.android.core.TwitterAuthToken
E/Parcel ( 814): java.lang.ClassNotFoundException: com.twitter.sdk.android.core.TwitterAuthToken
E/Parcel ( 814): at java.lang.Class.classForName(Native Method)
E/Parcel ( 814): at java.lang.Class.forName(Class.java:251)
E/Parcel ( 814): at java.lang.Class.forName(Class.java:216)
E/Parcel ( 814): at android.os.Parcel.readParcelableCreator(Parcel.java:2133)
E/Parcel ( 814): at android.os.Parcel.readParcelable(Parcel.java:2097)
E/Parcel ( 814): at android.os.Parcel.readValue(Parcel.java:2013)
E/Parcel ( 814): at android.os.Parcel.readArrayMapInternal(Parcel.java:2314)
E/Parcel ( 814): at android.os.Bundle.unparcel(Bundle.java:249)
E/Parcel ( 814): at android.os.Bundle.getString(Bundle.java:1118)
E/Parcel ( 814): at android.content.Intent.getStringExtra(Intent.java:4991)
E/Parcel ( 814): at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1353)
E/Parcel ( 814): at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:977)
E/Parcel ( 814): at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:3936)
E/Parcel ( 814): at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:3839)
E/Parcel ( 814): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:159)
E/Parcel ( 814): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2546)
E/Parcel ( 814): at android.os.Binder.execTransact(Binder.java:404)
E/Parcel ( 814): at dalvik.system.NativeStart.run(Native Method)
E/Parcel ( 814): Caused by: java.lang.NoClassDefFoundError: com/twitter/sdk/android/core/TwitterAuthToken
E/Parcel ( 814): … 18 more
E/Parcel ( 814): Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.twitter.sdk.android.core.TwitterAuthToken” on path: DexPathList[[directory “.”],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/Parcel ( 814): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
E/Parcel ( 814): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
E/Parcel ( 814): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
E/Parcel ( 814): … 18 more

… and…

E/TweetUploadService( 1145): Post Tweet failed
E/TweetUploadService( 1145): com.twitter.sdk.android.core.TwitterApiException: HTTP request failed, Status: 403
E/TweetUploadService( 1145): at com.twitter.sdk.android.core.Callback.onResponse(Callback.java:42)
E/TweetUploadService( 1145): at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:68)
E/TweetUploadService( 1145): at android.os.Handler.handleCallback(Handler.java:733)
E/TweetUploadService( 1145): at android.os.Handler.dispatchMessage(Handler.java:95)
E/TweetUploadService( 1145): at android.os.Looper.loop(Looper.java:157)
E/TweetUploadService( 1145): at android.app.ActivityThread.main(ActivityThread.java:5356)
E/TweetUploadService( 1145): at java.lang.reflect.Method.invokeNative(Native Method)
E/TweetUploadService( 1145): at java.lang.reflect.Method.invoke(Method.java:515)
E/TweetUploadService( 1145): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
E/TweetUploadService( 1145): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
E/TweetUploadService( 1145): at dalvik.system.NativeStart.main(Native Method)

Been looking around for what the error meant, and thought maybe it’s an authentication problem. I actually sent two whitelist requests, one for Android, and then another for iOS, since they have different Client Application IDs on my Fabric dashboard. The confirmation email never specified which got whitelisted, or if both got whitelisted. I initially thought, well, it’s the same app, so getting just one email for two requests makes sense. Am I wrong to think this?

There’s also the possibility that it’s the “can’t find com.twitter.sdk.android.core.TwitterAuthToken” error’s fault, but I’m completely blank on this.

Anyone got similar problems?


#2

Hey @kunehostudio,

Can you share the package name of your Android app so that I can look into any potential key issues?

-Mike


#3

Thanks, @bonnell. It’s
com.MiAs.GoldenDuck


#4

Thanks, I am seeing the correct permissions so it seems like something stranger is going on. Can you share the code you’re using to post?


#5

Sure!

private const string ScreenshotPathName	 = "/twitter_share_graphic.png";
private const string GooglePlayID = "com.MiAs.GoldenDuck";
private const string IPhoneID = "1176586699";
private const string IPadID = "1176586699";
private const string TwitterHashtag = "#GoldenDuck";

private void TwitterStartLogin()
{
	TwitterSession session = Twitter.Session;
	if (session == null)
	{
		Twitter.LogIn(TwitterLoginComplete, TwitterLoginFailure);
	}
	else
	{
		TwitterLoginComplete(session);
	}
}

private void TwitterLoginComplete(TwitterSession session)
{
	// Get the image URI
	StringBuilder imgURI = new StringBuilder();
	#if UNITY_ANDROID
	imgURI.Append("file://");
	#endif
	imgURI.Append(Application.persistentDataPath);
	imgURI.Append(ScreenshotPathName);
	
	// Start composer
	TwitterStartComposer(session, imgURI.ToString());
}

private void TwitterLoginFailure (ApiError error)
{
	Debug.LogError("code=" + error.code + " msg=" + error.message);
}

private void TwitterStartComposer(TwitterSession session, string imageUri)
{
	Card card = new AppCardBuilder()
		.ImageUri(imageUri)
		.GooglePlayId(GooglePlayID)
		.IPhoneId(IPhoneID)
		.IPadId(IPadID);

	Twitter.Compose(session, card, new string[]{TwitterHashtag});
}

That’s basically all the code I have, mostly just following the sample from the docs.


#6

Hi, Did you resolve the issue? I’m getting the same problem. Thanks!