NoClass Found error in Android studio (Lower than 5.0)


#1

After added twitter dependency to the app, app crashes with noClass found error.

compile('com.twitter.sdk.android:twitter:1.3.1@aar') {
        transitive = true;
}

For lollypop device, it works fine. but for kitkat device & emulator, it crashes with this error.

java.lang.NoClassDefFoundError: android.support.v7.app.ActionBarActivityDelegateHC

I’ve using single ActionbarActivity to inflate a Twitter Login button.
If I changed ActionbarActivity to Activity, then it crashes with NoClassDefFoundError:gson.

Another plugin like crashlytics and mopub work fine for kitkat, it only happens for twitter/tweet-composer.

Any way to solve this problem?
I’ve already found several posts from stackoverflow, but it didn’t work for me.


#2

Hi ringsterz,

The twitter artifact has the following dependencies:
– digits
– tweet-ui
– picasso
– support-v4 (android)
– tweet-composer
– twitter-core
– gson
– retrofit

From the error, it seems like your build is missing some dependencies. Have you tried downloading the dependencies again?

./gradlew --refresh-dependencies

Lien


#3

Still no luck.
Building a project is fine.
App runs on Lollipop devices without any error. But it still crashes at runtime on kitkat devices(4.2, 4.4).


#4

Hi, I had the same problem and I solved it using proper multiDexEnabled;
You can see the solution here:
https://twittercommunity.com/t/android-twitter-crashes-with-appcompat-v7-on-api-19-and-lower/34121/2?source_topic_id=33518

or here:

https://developer.android.com/tools/building/multidex.html


#5

Thanks for help.
After adding a dependency and following line to manifest, problem solved. :smile:
android:name="android.support.multidex.MultiDexApplication"


#6