0

I am using a Samsung Galaxy S5 to test my android app. It is a hello world app. So what is occurring is that every time I run the app onto my device it opens the hello world app but then immediately crashes giving me this error:

06-14 01:45:59.356: E/AndroidRuntime(28817): FATAL EXCEPTION: main
06-14 01:45:59.356: E/AndroidRuntime(28817): Process: com.example.crystalball, PID: 28817
06-14 01:45:59.356: E/AndroidRuntime(28817): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at com.example.crystalball.MainActivity.onCreate(MainActivity.java:18)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.app.Activity.performCreate(Activity.java:5451)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.app.ActivityThread.access$900(ActivityThread.java:169)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.os.Handler.dispatchMessage(Handler.java:102)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.os.Looper.loop(Looper.java:136)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.app.ActivityThread.main(ActivityThread.java:5476)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at java.lang.reflect.Method.invokeNative(Native Method)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at java.lang.reflect.Method.invoke(Method.java:515)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at dalvik.system.NativeStart.main(Native Method)

I have no idea what it means so any help would be much appreciated.

FIX: I had to add the appcompat to the main gen file on the project. Thanks for all the help!

user3358306
  • 187
  • 1
  • 13
  • 1
    Please post the code for `MainActivity.java` and tell us where line 18 is. – Code-Apprentice Jun 14 '14 at 06:00
  • search `java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable` on google and see related links like http://stackoverflow.com/questions/17851783/error-implementing-support-library-action-bar – Shayan Pourvatan Jun 14 '14 at 06:16

2 Answers2

0

There are two main causes for this problem:

  1. You have not imported the appcompat-v7 library in your project, or
  2. You don't have the correct theme in the AndroidManifest.xml file. It should be android:theme="@style/Theme.AppCompat" (or Theme.AppCompat.Light, &c).
matiash
  • 54,791
  • 16
  • 125
  • 154
0

Issue are clearly highlighted in the Logcat:

java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable 
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
06-14 01:45:59.356: E/AndroidRuntime(28817):    at com.example.crystalball.MainActivity.onCreate(MainActivity.java:18)

In the above the first indicates that:

  1. You've not imported the appcompat-v7 to your project or You don't have the right theme in your AndroidManifest.xml file. It should be android:theme="@style/Theme.AppCompat"
  2. The last line indicates that, in your MainActivity.Java line-18 has the issue.. Please either post your code

First try with #1 - that should hopefully resolve the issue.

Ramakishna Balla
  • 1,020
  • 1
  • 8
  • 12