Hi there.
We are using Unity 5.3.4f1 and want to integrate Twitter into our app. We decided to start with a blank Unity project to smoothen the process of getting tweets working before moving it into the main branch of our project. However we have not been able to successfully tweet. The steps we took to integrate Twitter are:
- Signup up for Fabric and download the TwitterKit Unity package, as mentioned here https://docs.fabric.io/unity/fabric/overview.html.
- Open the package in Unity.
- Follow the Fabric integration steps in Unity by selecting Fabric -> Prepare Fabric, entering Fabric account details and selecting the Twitter Kit.
- Implemented code as per the instructions on the site provided above.
The error we are getting is:
E/Parcel (22200): Class not found when unmarshalling: com.twitter.sdk.android.core.TwitterAuthToken
E/Parcel (22200): java.lang.ClassNotFoundException: com.twitter.sdk.android.core.TwitterAuthToken
E/Parcel (22200): at java.lang.Class.classForName(Native Method)
E/Parcel (22200): at java.lang.Class.forName(Class.java:309)
E/Parcel (22200): at java.lang.Class.forName(Class.java:273)
E/Parcel (22200): at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
E/Parcel (22200): at android.os.Parcel.readParcelable(Parcel.java:2245)
E/Parcel (22200): at android.os.Parcel.readValue(Parcel.java:2152)
E/Parcel (22200): at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)
E/Parcel (22200): at android.os.BaseBundle.unparcel(BaseBundle.java:221)
E/Parcel (22200): at android.os.BaseBundle.getString(BaseBundle.java:918)
E/Parcel (22200): at android.content.Intent.getStringExtra(Intent.java:5247)
E/Parcel (22200): at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1502)
E/Parcel (22200): at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1086)
E/Parcel (22200): at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4347)
E/Parcel (22200): at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:4246)
E/Parcel (22200): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:144)
E/Parcel (22200): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2791)
E/Parcel (22200): at android.os.Binder.execTransact(Binder.java:446)
E/Parcel (22200): 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 (22200): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/Parcel (22200): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/Parcel (22200): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/Parcel (22200): … 17 more
E/Parcel (22200): Suppressed: java.lang.ClassNotFoundException: com.twitter.sdk.android.core.TwitterAuthToken
E/Parcel (22200): at java.lang.Class.classForName(Native Method)
E/Parcel (22200): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/Parcel (22200): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/Parcel (22200): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/Parcel (22200): … 18 more
E/Parcel (22200): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I/ActivityManager(22200): START u0 {cmp=net.pluginmedia.nationalnumeracyrunner/com.twitter.sdk.android.tweetcomposer.ComposerActivity (has extras)} from uid 10180 on display 0
And the code we are using is:
protected static string cachedImagePath = “”;
public static void ShareImageViaTwitter(string imagePath)
{
cachedImagePath = imagePath;
if (!cachedImagePath.StartsWith("file://"))
{
cachedImagePath = "file://" + cachedImagePath;
}
if(Twitter.Session == null){
Twitter.LogIn(TwitterResultHandler);
}else{
Card card = new AppCardBuilder()
.ImageUri(cachedImagePath)
.GooglePlayId("com.example.ourapp");
Twitter.Compose(Twitter.Session, card);
}
}
protected static void TwitterResultHandler(TwitterSession currentSession)
{
if(currentSession != null){
ShareImageViaTwitter(cachedImagePath);
}
}
The tweet dialogue successfully appears with our image, but on pressing the “Tweet” button it doesn’t Tweet to the user’s timeline, and we get this error:
E/TweetUploadService(17314): Post Tweet failed
E/TweetUploadService(17314): com.twitter.sdk.android.core.TwitterApiException: 403 Forbidden
E/TweetUploadService(17314): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:383)
E/TweetUploadService(17314): at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
E/TweetUploadService(17314): at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
E/TweetUploadService(17314): at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
E/TweetUploadService(17314): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
E/TweetUploadService(17314): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/TweetUploadService(17314): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/TweetUploadService(17314): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/TweetUploadService(17314): at java.lang.Thread.run(Thread.java:818)
Is there anything obvious we are missing out? Any help would be much appreciated.
Thanks,
James.