java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable

i am using terminal [not eclipse]. i got following exception error, while i use emulator.debug successfully and installd successfully. But emulator show Unfortunatly app has stop. Then i run $ adb logcat it will display following.

java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
at com.example.trintwo.MainActivity.onCreate(MainActivity.java:19)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)

I got this error, Even I installed android support library and i checked android-support-v7-appcompat.jar in android/support/v7/appcompat/lib path what will i do to clear this error.


Solution 1:

Make sure to do the following (from Support Library Setup):

  1. Right-click the library project folder and select Build Path > Configure Build Path.

  2. In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.

  3. Uncheck Android Dependencies.

Solution 2:

If you are using eclipse than just import the v7 compat library project into your work space and add it as a library to your project. Else if you are doing it from terminal than what you can do is put android-support-v7-appcompat library project (which you can find in sdk\extras\android\support\v7\appcompat) in the same directory where is your project and add this line to your project.properties file.

android.library.reference.1=../android-support-v7-appcompat

Do not forget to add both jar files v4, v7 to your project as well.

Solution 3:

AppCompat is a lib with resource. You cannot add the jar, cause this library uses resources. So you need to add a library project.

Follow Adding Support Libraries steps.