maps - java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable in android -


i tried demo on displaying google maps v2 in android.

the java code is,

package com.example.gpslocator;  import android.os.bundle; import android.app.activity; import android.view.menu;  public class mainactivity extends activity {  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main); }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true; }     } 

the xml code is,

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" >  <fragment        android:id="@+id/map"       android:layout_width="match_parent"       android:layout_height="match_parent"       android:name="com.google.android.gms.maps.mapfragment"/> </linearlayout> 

i added api key in manifest.xml,

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.gpslocator" android:versioncode="1" android:versionname="1.0" >  <uses-sdk     android:minsdkversion="3"     android:targetsdkversion="17" />  <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <!--  following 2 permissions not required use  google maps android api v2, recommended. --> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" />  <permission     android:name="com.example.mapdemo.permission.maps_receive"     android:protectionlevel="signature" />  <uses-permission android:name="com.example.mapdemo.permission.maps_receive" />  <uses-feature     android:glesversion="0x00020000"     android:required="true" />  <application     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name="com.example.gpslocator.mainactivity"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>      <meta-data         android:name="com.google.android.maps.v2.api_key"         android:value="my_api_key" /> </application>  </manifest> 

when tried run application closes of suddenly. when debug, showed me error, "java.lang.noclassdeffounderror: com.google.android.gms.r$styleable". added google-play-services.jar file application.

the logcat is,

04-09 05:33:53.677: e/trace(1053): error opening trace file: no such file or directory (2) 04-09 05:33:53.807: w/activitythread(1053): application com.example.gpslocator waiting debugger on port 8100... 04-09 05:33:53.878: i/system.out(1053): sending wait chunk 04-09 05:33:54.207: i/dalvikvm(1053): debugger active 04-09 05:33:54.288: i/system.out(1053): debugger has connected 04-09 05:33:54.288: i/system.out(1053): waiting debugger settle... 04-09 05:33:54.487: i/system.out(1053): waiting debugger settle... 04-09 05:33:54.697: i/system.out(1053): waiting debugger settle... 04-09 05:33:54.897: i/system.out(1053): waiting debugger settle... 04-09 05:33:55.097: i/system.out(1053): waiting debugger settle... 04-09 05:33:55.297: i/system.out(1053): waiting debugger settle... 04-09 05:33:55.498: i/system.out(1053): waiting debugger settle... 04-09 05:33:55.708: i/system.out(1053): waiting debugger settle... 04-09 05:33:55.907: i/system.out(1053): waiting debugger settle... 04-09 05:33:56.167: i/system.out(1053): waiting debugger settle... 04-09 05:33:56.367: i/system.out(1053): debugger has settled (1344) 04-09 05:34:06.097: w/dalvikvm(1053): vfy: unable resolve static field 867 (mapattrs) in lcom/google/android/gms/r$styleable; 04-09 05:34:06.097: d/dalvikvm(1053): vfy: replacing opcode 0x62 @ 0x000e 04-09 05:40:21.278: d/androidruntime(1053): shutting down vm 04-09 05:40:21.278: w/dalvikvm(1053): threadid=1: thread exiting uncaught exception (group=0x40a71930) 04-09 05:40:21.398: e/androidruntime(1053): fatal exception: main 04-09 05:40:21.398: e/androidruntime(1053): java.lang.noclassdeffounderror: com.google.android.gms.r$styleable 04-09 05:40:21.398: e/androidruntime(1053):     @ com.google.android.gms.maps.googlemapoptions.createfromattributes(unknown source) 04-09 05:40:21.398: e/androidruntime(1053):     @ com.google.android.gms.maps.mapfragment.oninflate(unknown source) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.activity.oncreateview(activity.java:4716) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:680) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.view.layoutinflater.rinflate(layoutinflater.java:746) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.view.layoutinflater.inflate(layoutinflater.java:489) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.view.layoutinflater.inflate(layoutinflater.java:396) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.view.layoutinflater.inflate(layoutinflater.java:352) 04-09 05:40:21.398: e/androidruntime(1053):     @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:270) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.activity.setcontentview(activity.java:1881) 04-09 05:40:21.398: e/androidruntime(1053):     @ com.example.gpslocator.mainactivity.oncreate(mainactivity.java:12) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.activity.performcreate(activity.java:5104) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.activitythread.access$600(activitythread.java:141) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.os.handler.dispatchmessage(handler.java:99) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.os.looper.loop(looper.java:137) 04-09 05:40:21.398: e/androidruntime(1053):     @ android.app.activitythread.main(activitythread.java:5041) 04-09 05:40:21.398: e/androidruntime(1053):     @ java.lang.reflect.method.invokenative(native method) 04-09 05:40:21.398: e/androidruntime(1053):     @ java.lang.reflect.method.invoke(method.java:511) 04-09 05:40:21.398: e/androidruntime(1053):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 04-09 05:40:21.398: e/androidruntime(1053):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 04-09 05:40:21.398: e/androidruntime(1053):     @ dalvik.system.nativestart.main(native method) 04-09 05:40:26.487: i/process(1053): sending signal. pid: 1053 sig: 9 

in properties-->android-->

enter image description here

please 1 me out. missing reference?

see answer here:
google maps android api v2 - sample code crashes
while question lists different exception, answer mentions exact problem.

specifically, it's important import google-play-services_lib project:
select file > import > android > existing android code workspace , click next.
select browse..., enter [android-sdk-folder]/extras/google/google_play_services/libproject/google-play-services_lib, , click finish.
(see https://developers.google.com/maps/documentation/android/intro under "sample code")
follow instructions linked answer:

  • import actual source "google-play-services_lib" project , link >android library.
    • do through project -> properties -> android -> library, add -> google-play-services_lib (you can right click on project , choose properties, select android).
    • do not add dependent project through "java build path" project, didn't work me.

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -