I am trying to implement the most basic example of google maps android api v2 example. But it crashes with the error:java.lang.NoClassDefFoundError: com.google.android.gms.R$sty
Use Android SDK Manager download "google play services"
import it into your workspace (path: android-sdk root/extras/google/google_play_service/libproject/google-play-service_lib)
project Properties -> android -> Library add google-play-service_lib
Build path -> Order and Export check Android private libraries
I solved this error by checking "Copy projects into workspace" while importing the Google Play Services lib. More info here: http://developer.android.com/google/play-services/setup.html
Please check if the "libs" folder containing the "android-support-v4.jar" exists in your project. Because you are using Android 2.2, you must have "libs " folder in your project root directory. If you have not that, just copy that jar file into your "libs" folder .
"android-support-v4.jar" is located in "/extras/android/compatibility/v4/android-support-v4.jar" under your drectory.
And before running your project, you must set your project Build target to "Google APIs", not Android x.x. version : Select your project and click Project > Properties > Project Build Target in Eclipse and select any "Google APIs ", and then run your project on your phone. If you use the emulator, also MUST set the AVD of the emulator to the any "Google APIs ".
Once more, you don't need to create the new Google Maps API key in order to test your project, Just use the default provided API key, which is shown as "Key for browser apps (with referers) "in your Google APIs Console.