Tuesday, 15 February 2011

android - google maps api v2 -



android - google maps api v2 -

i trying run basic illustration of google maps api v2 http://www.vogella.com/articles/androidgooglemaps/article.html keeps crashing error:

02-10 14:51:38.292: e/androidruntime(898): fatal exception: main 02-10 14:51:38.292: e/androidruntime(898): java.lang.noclassdeffounderror: com.google.android.gms.r$styleable 02-10 14:51:38.292: e/androidruntime(898): @ com.google.android.gms.maps.googlemapoptions.createfromattributes(unknown source) 02-10 14:51:38.292: e/androidruntime(898): @ com.google.android.gms.maps.mapfragment.oninflate(unknown source) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.activity.oncreateview(activity.java:4716) 02-10 14:51:38.292: e/androidruntime(898): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:680) 02-10 14:51:38.292: e/androidruntime(898): @ android.view.layoutinflater.rinflate(layoutinflater.java:746) 02-10 14:51:38.292: e/androidruntime(898): @ android.view.layoutinflater.inflate(layoutinflater.java:489) 02-10 14:51:38.292: e/androidruntime(898): @ android.view.layoutinflater.inflate(layoutinflater.java:396) 02-10 14:51:38.292: e/androidruntime(898): @ android.view.layoutinflater.inflate(layoutinflater.java:352) 02-10 14:51:38.292: e/androidruntime(898): @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:270) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.activity.setcontentview(activity.java:1881) 02-10 14:51:38.292: e/androidruntime(898): @ com.vogella.android.locationapi.maps.mainactivity.oncreate(mainactivity.java:23) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.activity.performcreate(activity.java:5104) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.activitythread.access$600(activitythread.java:141) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 02-10 14:51:38.292: e/androidruntime(898): @ android.os.handler.dispatchmessage(handler.java:99) 02-10 14:51:38.292: e/androidruntime(898): @ android.os.looper.loop(looper.java:137) 02-10 14:51:38.292: e/androidruntime(898): @ android.app.activitythread.main(activitythread.java:5039) 02-10 14:51:38.292: e/androidruntime(898): @ java.lang.reflect.method.invokenative(native method) 02-10 14:51:38.292: e/androidruntime(898): @ java.lang.reflect.method.invoke(method.java:511) 02-10 14:51:38.292: e/androidruntime(898): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 02-10 14:51:38.292: e/androidruntime(898): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 02-10 14:51:38.292: e/androidruntime(898): @ dalvik.system.nativestart.main(native method)

my code...

manifest:

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.vogella.android.locationapi.maps" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="17" android:targetsdkversion="17" /> <permission android:name="com.example.mapdemo.permission.maps_receive" android:protectionlevel="signature" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-permission android:name="com.example.mapdemo.permission.maps_receive" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.vogella.android.locationapi.maps.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="{tried both browser api key , android api keys here}" /> </application> </manifest>

layout:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".mainactivity" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.mapfragment" /> </relativelayout>

activity:

package com.vogella.android.locationapi.maps; import android.app.activity; import android.os.bundle; import android.view.menu; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.mapfragment; import com.google.android.gms.maps.model.bitmapdescriptorfactory; import com.google.android.gms.maps.model.latlng; import com.google.android.gms.maps.model.marker; import com.google.android.gms.maps.model.markeroptions; public class mainactivity extends activity { static final latlng hamburg = new latlng(53.558, 9.927); static final latlng kiel = new latlng(53.551, 9.993); private googlemap map; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); map = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap(); marker hamburg = map.addmarker(new markeroptions().position(hamburg).title("hamburg")); marker kiel = map.addmarker(new markeroptions() .position(kiel) .title("kiel") .snippet("kiel cool") .icon(bitmapdescriptorfactory.fromresource(r.drawable.ic_launcher))); // move photographic camera instantly hamburg zoom of 15. map.movecamera(cameraupdatefactory.newlatlngzoom(hamburg, 15)); // zoom in, animating camera. map.animatecamera(cameraupdatefactory.zoomto(10), 2000, null); } @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.activity_main, menu); homecoming true; } }

of ran on avd target google api 17, crashes immediately.

i noticed have not added protection google play services, google maps v2 api requires run.

the issue maybe due google play services not beingness supported on avd. seek running on device.

maybe these can help

missing google play services avd

http://stackoverflow.com/a/14282347/1788333

android noclassdeffounderror avd google-maps-android-api-2

No comments:

Post a Comment