NoClassDefFoundError com.twitter.sdk.android.tweetui.internal.ActiveSessionProvider

android

#1

Hi i have problems with the Twitter SDK it seems like it is not been exported or something in devices lower than 5.0, it works great in my nexus with 5.1.1, but in other devices the app simple crash, i dont know it is happening, i followed the steps from Fabric in Android Studio but nothing seems to work, i use Twitter and Crashlytics, hope you guys can help me.

05-28 18:26:19.323  13580-13580/com.appsorama.fortunecookie E/Trace﹕ error opening trace file: No such file or directory (2)
05-28 18:26:19.436  13580-13580/com.appsorama.fortunecookie E/dalvikvm﹕ Could not find class 'com.twitter.sdk.android.tweetui.internal.ActiveSessionProvider', referenced from method com.twitter.sdk.android.tweetui.TweetUi.onPreExecute
05-28 18:26:19.612  13580-13580/com.appsorama.fortunecookie E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.twitter.sdk.android.tweetui.internal.ActiveSessionProvider
            at com.twitter.sdk.android.tweetui.TweetUi.onPreExecute(TweetUi.java:76)
            at io.fabric.sdk.android.InitializationTask.onPreExecute(InitializationTask.java:44)
            at io.fabric.sdk.android.services.concurrency.AsyncTask.executeOnExecutor(AsyncTask.java:611)
            at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.executeOnExecutor(PriorityAsyncTask.java:43)
            at io.fabric.sdk.android.Kit.initialize(Kit.java:66)
            at io.fabric.sdk.android.Fabric.initializeKits(Fabric.java:437)
            at io.fabric.sdk.android.Fabric.init(Fabric.java:381)
            at io.fabric.sdk.android.Fabric.setFabric(Fabric.java:338)
            at io.fabric.sdk.android.Fabric.with(Fabric.java:309)
            at com.appsorama.fortunecookie.Application.onCreate(Application.java:43)

Here is my Gradle:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'io.fabric'

android {
    compileSdkVersion 21
    buildToolsVersion '22.0.1'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.1.2"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/SessionM.1.10.0.jar')
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.google.android.gms:play-services:7.0.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
    compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
    compile 'com.github.traex.rippleeffect:library:1.2.4'
    compile 'com.mcxiaoke.volley:library:1.0.15'
    compile('com.twitter.sdk.android:twitter:1.5.1@aar') {
        transitive = true;
    }
    compile(
            [group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.4.1'],
            [group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.4.1'],
            [group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.4.1']
    )
    compile project(':libraries:facebook')
    compile('com.crashlytics.sdk.android:crashlytics:2.3.1@aar') {
        transitive = true;
    }

}

And Finally my Application Class:

TwitterAuthConfig authConfig = new TwitterAuthConfig(TwitterUtil.API_KEY, TwitterUtil.API_SECRET);
        Fabric.with(this, new Twitter(authConfig), new TweetComposer(), new Crashlytics());

I have cleaned the project, added this line in my proguard file

-include ../proguard-com.twitter.sdk.android.twitter.txt

#2

What’s your multidex support setup for pre-5.0? Since you enabled multidex and see correct behavior on Android 5.0+ ART runtime devices and class loading issues on earlier versions, this sounds like a multidex configuration problem.

The tweetui.internal class files are there if you unpack and poke around. Also, no need for “new TweetComposer”, the Twitter kit includes TweetComposer, TweetUi, and TwitterCore already.


#3