0

I have just downloaded and started using the android SDK and have followed their instructions on creating "my first app" which says "Hello World." I have not changed anything in the code. I am running a Nexus 7 emulator (only one that doesn't crash every time I run it). When I run the app, on the emulator it says "Unfortunately my first app has stopped working."

Here is the logcat:

05-16 13:05:48.742: W/dalvikvm(1066): VFY: unable to resolve static field 1559 (ActionBarWindow) in Landroid/support/v7/appcompat/R$styleable;
05-16 13:05:48.742: D/dalvikvm(1066): VFY: replacing opcode 0x62 at 0x0004
05-16 13:05:48.752: D/AndroidRuntime(1066): Shutting down VM
05-16 13:05:48.752: W/dalvikvm(1066): threadid=1: thread exiting with uncaught exception (group=0xb2ac5ba8)
05-16 13:05:48.812: E/AndroidRuntime(1066): FATAL EXCEPTION: main
05-16 13:05:48.812: E/AndroidRuntime(1066): Process: com.example.myfirstapp, PID: 1066
05-16 13:05:48.812: E/AndroidRuntime(1066): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:107)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at com.example.myfirstapp.MainActivity.onCreate(MainActivity.java:18)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.app.Activity.performCreate(Activity.java:5231)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.os.Handler.dispatchMessage(Handler.java:102)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.os.Looper.loop(Looper.java:136)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at android.app.ActivityThread.main(ActivityThread.java:5017)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at java.lang.reflect.Method.invokeNative(Native Method)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at java.lang.reflect.Method.invoke(Method.java:515)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-16 13:05:48.812: E/AndroidRuntime(1066):     at dalvik.system.NativeStart.main(Native Method)
05-16 13:05:51.822: I/Process(1066): Sending signal. PID: 1066 SIG: 9

Any thoughts? Again, this is the default code upon creating a new app, so I'm not sure why it wouldn't work... Thanks for the help

Lal
  • 14,726
  • 4
  • 45
  • 70
user2976670
  • 29
  • 3
  • 9
  • 3
    `java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable` you need to reference AppCompat in your android project properly – Raghunandan May 16 '14 at 17:09
  • 2
    it's complaining about a missing class "android.support.v7.appcompat.R" . These classes belong to what is called "Android Support Library". Check you have support library installed in **Android SDK Manager** and your project properties – rupps May 16 '14 at 17:11
  • 1
    Right click on your project, Click Properties/Android and scroll down to Library. Then add the AppCompat library reference – Phantômaxx May 16 '14 at 17:11
  • https://developer.android.com/tools/support-library/features.html and https://developer.android.com/tools/support-library/setup.html for more documentation about this library and setting it up. – CommonsWare May 16 '14 at 17:12

1 Answers1

2

This is how I solved this problem:

  1. Import support library as a project from "sdk/extras/android/support/v7/appcompat".
  2. Reference library in your project (for Eclipse, "Properties - Android - Add").
  3. Build projects (for Eclipse, "Projects - Build All"). Make sure, you have "android.support.v7.appcompat" in your main project gen folder.
  4. If it doesn't worked - clean and rebuild project.

and if you have the jar file already in libs folder then first Delete the jar from the libs folder and then do the above steps..

Ensure that your in yout Manifest.xml your activity has the correct theme

<activity
    android:name="***.*****.******"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.Light"
     >

Hope it helps..

Lal
  • 14,726
  • 4
  • 45
  • 70