0

I just updated my android studio project to latest SDK version and its not working. Gradle sync is successful but app crashes on launch.

Here is the crash :

java.lang.NoClassDefFoundError: android.support.v7.app.ActionBarActivityDelegateICS
            at android.support.v7.app.ActionBarActivityDelegate.createDelegate(ActionBarActivityDelegate.java:47)
            at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:96)
            at <package>.MainActivity.onCreate(MainActivity.java:170)
            at android.app.Activity.performCreate(Activity.java:5541)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2507)
            at android.app.ActivityThread.access$900(ActivityThread.java:172)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5692)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)

Here are the lines in my dependencies tag in build.gradle :

compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'

My build.gradle - http://pastebin.com/NvrWZfEj

Faisal Memon
  • 774
  • 3
  • 12
  • 28

3 Answers3

0

The problem is probably not in your code but in the build aka in the compilation so here is what I did to fix error message which were misguiding after an upgrade to 5.0 version

For me same problem was gone after recompiling the project with android 5 api 21

Choose project right click than alt-enter in eclipse compile with your device current os

sivi
  • 10,654
  • 2
  • 52
  • 51
  • Hey, can you tell me how to do that in studio? – Faisal Memon Dec 30 '14 at 07:58
  • Im no expert on Studio. But generaly i think the answer and information about building can be found here https://developer.android.com/sdk/installing/studio-build.html – sivi Dec 30 '14 at 11:18
0

Your normally get 'NoClassDefFoundError' when the Class you are using is available at compile time ; but not at runtime.

NoClassDefFoundError

So my guess is ; you are using the Emulator/Device (in which your application is Run), which has Android version different from Android L(the one you Compiled your code with). So believe you can either upgrade your emulator/device to Android L...or probably set the 'minSdkVersion'(in build.gradle) to resolve the InCompatibility Issues. Hope this helps.

Community
  • 1
  • 1
Raj
  • 2,368
  • 6
  • 34
  • 52
-1

I faced the same issue. Instead of trying to fix the old project, I removed the old project and started new one and copy pasted the legacy code one functionality at a time.

Sometimes, It is simply not worth figuring out why or what.

appbootup
  • 9,537
  • 3
  • 33
  • 65