0

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$styleable.

I have set up the google api and have looked at stackoverflow posts like:

but their problems are slightly different than mine.

Can you please point me to the right direction? I am using android 2.2 and would like to use the new Maps to make use of fragments in my app; so that I can get some functionality like apple's uinavigation to push new views in a pop up activity.

Thanks.

Thank you,how did you get to the png you are showing in the attachment?The google play service is shown as a referenced library in my package explorer; I did add it; this is my logcat:

01-16 06:23:55.087: E/AndroidRuntime(305): FATAL EXCEPTION: main
01-16 06:23:55.087: E/AndroidRuntime(305): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
01-16 06:23:55.087: E/AndroidRuntime(305):  at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
01-16 06:23:55.087: E/AndroidRuntime(305):  at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:271)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:558)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-16 06:23:55.087: E/AndroidRuntime(305):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.app.Activity.setContentView(Activity.java:1647)
01-16 06:23:55.087: E/AndroidRuntime(305):  at com.example.afis.MainActivity.onCreate(MainActivity.java:13)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.os.Looper.loop(Looper.java:123)
01-16 06:23:55.087: E/AndroidRuntime(305):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-16 06:23:55.087: E/AndroidRuntime(305):  at java.lang.reflect.Method.invokeNative(Native Method)
01-16 06:23:55.087: E/AndroidRuntime(305):  at java.lang.reflect.Method.invoke(Method.java:521)
01-16 06:23:55.087: E/AndroidRuntime(305):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-16 06:23:55.087: E/AndroidRuntime(305):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-16 06:23:55.087: E/AndroidRuntime(305):  at dalvik.system.NativeStart.main(Native Method)
01-16 06:23:55.097: W/ActivityManager(59):   Force finishing activity com.example.afis/.MainActivity
01-16 06:23:55.607: W/ActivityManager(59): Activity pause timeout for HistoryRecord{44ee9110 com.example.afis/.MainActivity}
Community
  • 1
  • 1
ngwane
  • 133
  • 1
  • 4
  • 8

3 Answers3

0

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.

BBonDoo
  • 766
  • 5
  • 14
  • I have added the support-v4.jar to my lib directory. And the target has also been set to Google APIs.Fido; the link you gave me has been useful; it has solved the classNotFound Error. My map is no longer bombing out; the only problem now is that it is saying google Play services need to be installed in my emulator. If I click the button to get it; it bombs out throwing an error that says there is no activity that can handle the intent. How do I install activity to handle such a request? Or how do I install google play in the emulator? – ngwane Jan 16 '13 at 10:32
  • I recommend that you use your real phone, not the emulator. About the how to install it in the emulator, you can find it through the google searching, but I think that is very consuming your times. On your Android 2.2, try to test your app, please. – BBonDoo Jan 16 '13 at 11:16
  • @mugum you can try this to install google play on emulator ^^. see this one: http://stackoverflow.com/a/13734937/1821326 and this is my config: http://stackoverflow.com/a/14271933/1821326 – Fido Jan 16 '13 at 13:30
0
  1. Use Android SDK Manager download "google play services"

  2. import it into your workspace (path: android-sdk root/extras/google/google_play_service/libproject/google-play-service_lib)

  3. project Properties -> android -> Library add google-play-service_lib

  4. Build path -> Order and Export check Android private libraries

iceboxi
  • 49
  • 7
0

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

Umberto
  • 2,011
  • 1
  • 23
  • 27