android - Building Google Maps API v2 application but unfortunately .apk has stop working -
i trying build application using google maps api v2 thing is, application keeps giving me error unfortunately .apk has stop working although followed required instructions. please see code , me figure out problem. in advance
here app code
package com.example.ugoogle; import android.os.bundle; import android.view.menu; import android.view.menuitem; import com.google.android.maps.mapactivity; import com.google.android.maps.mapview; public class mainactivity extends mapactivity { mapview maps; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); maps = (mapview) findviewbyid (r.id.mapsviewmain); maps.setbuiltinzoomcontrols(true); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } @override protected boolean isroutedisplayed() { // todo auto-generated method stub return false; } }
and here xml
<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" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.ugoogle.mainactivity" > <com.google.android.gms.maps.mapview android:layout_width="fill_parent" android:layout_height="fill_parent" android:apikey="my key generated on google here. trust me" android:id="@+id/mapsviewmain" android:enabled="true" android:clickable="true" /> </relativelayout>
here manifest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.ugoogle" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="21" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.access_network_state" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <uses-library android:name="com.google.android.maps" /> <activity android:name=".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 key generated on google here. trust me" /> </application> </manifest>
logcat
01-01 22:13:31.862: e/androidruntime(13016): fatal exception: main 01-01 22:13:31.862: e/androidruntime(13016): java.lang.runtimeexception: unable instantiate activity componentinfo{com.vogella.android.locationapi.maps/com.vogella.android.locationapi.maps.mainactivity}: java.lang.classnotfoundexception: didn't find class "com.vogella.android.locationapi.maps.mainactivity" on path: dexpathlist[[zip file "/data/app/com.vogella.android.locationapi.maps-1.apk"],nativelibrarydirectories=[/data/app-lib/com.vogella.android.locationapi.maps-1, /vendor/lib, /system/lib]] 01-01 22:13:31.862: e/androidruntime(13016): @ android.app.activitythread.performlaunchactivity(activitythread.java:2269) 01-01 22:13:31.862: e/androidruntime(13016): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2395) 01-01 22:13:31.862: e/androidruntime(13016): @ android.app.activitythread.access$600(activitythread.java:162) 01-01 22:13:31.862: e/androidruntime(13016): @ android.app.activitythread$h.handlemessage(activitythread.java:1364) 01-01 22:13:31.862: e/androidruntime(13016): @ android.os.handler.dispatchmessage(handler.java:107) 01-01 22:13:31.862: e/androidruntime(13016): @ android.os.looper.loop(looper.java:194) 01-01 22:13:31.862: e/androidruntime(13016): @ android.app.activitythread.main(activitythread.java:5371) 01-01 22:13:31.862: e/androidruntime(13016): @ java.lang.reflect.method.invokenative(native method) 01-01 22:13:31.862: e/androidruntime(13016): @ java.lang.reflect.method.invoke(method.java:525) 01-01 22:13:31.862: e/androidruntime(13016): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:833) 01-01 22:13:31.862: e/androidruntime(13016): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 01-01 22:13:31.862: e/androidruntime(13016): @ dalvik.system.nativestart.main(native method) 01-01 22:13:31.862: e/androidruntime(13016): caused by: java.lang.classnotfoundexception: didn't find class "com.vogella.android.locationapi.maps.mainactivity" on path: dexpathlist[[zip file "/data/app/com.vogella.android.locationapi.maps-1.apk"],nativelibrarydirectories=[/data/app-lib/com.vogella.android.locationapi.maps-1, /vendor/lib, /system/lib]] 01-01 22:13:31.862: e/androidruntime(13016): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:53) 01-01 22:13:31.862: e/androidruntime(13016): @ java.lang.classloader.loadclass(classloader.java:501) 01-01 22:13:31.862: e/androidruntime(13016): @ java.lang.classloader.loadclass(classloader.java:461) 01-01 22:13:31.862: e/androidruntime(13016): @ android.app.instrumentation.newactivity(instrumentation.java:1054) 01-01 22:13:31.862: e/androidruntime(13016): @ android.app.activitythread.performlaunchactivity(activitythread.java:2260) 01-01 22:13:31.862: e/androidruntime(13016): ... 11 more 01-01 22:13:31.927: e/apperrordialog(494): failed ilowstoragehandle instance 01-01 22:15:50.133: e/androidruntime(13111): fatal exception: main 01-01 22:15:50.133: e/androidruntime(13111): java.lang.runtimeexception: unable instantiate activity componentinfo{com.vogella.android.locationapi.maps/com.vogella.android.locationapi.maps.mainactivity}: java.lang.classnotfoundexception: didn't find class "com.vogella.android.locationapi.maps.mainactivity" on path: dexpathlist[[zip file "/data/app/com.vogella.android.locationapi.maps-2.apk"],nativelibrarydirectories=[/data/app-lib/com.vogella.android.locationapi.maps-2, /vendor/lib, /system/lib]] 01-01 22:15:50.133: e/androidruntime(13111): @ android.app.activitythread.performlaunchactivity(activitythread.java:2269) 01-01 22:15:50.133: e/androidruntime(13111): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2395) 01-01 22:15:50.133: e/androidruntime(13111): @ android.app.activitythread.access$600(activitythread.java:162) 01-01 22:15:50.133: e/androidruntime(13111): @ android.app.activitythread$h.handlemessage(activitythread.java:1364) 01-01 22:15:50.133: e/androidruntime(13111): @ android.os.handler.dispatchmessage(handler.java:107) 01-01 22:15:50.133: e/androidruntime(13111): @ android.os.looper.loop(looper.java:194) 01-01 22:15:50.133: e/androidruntime(13111): @ android.app.activitythread.main(activitythread.java:5371) 01-01 22:15:50.133: e/androidruntime(13111): @ java.lang.reflect.method.invokenative(native method) 01-01 22:15:50.133: e/androidruntime(13111): @ java.lang.reflect.method.invoke(method.java:525) 01-01 22:15:50.133: e/androidruntime(13111): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:833) 01-01 22:15:50.133: e/androidruntime(13111): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 01-01 22:15:50.133: e/androidruntime(13111): @ dalvik.system.nativestart.main(native method) 01-01 22:15:50.133: e/androidruntime(13111): caused by: java.lang.classnotfoundexception: didn't find class "com.vogella.android.locationapi.maps.mainactivity" on path: dexpathlist[[zip file "/data/app/com.vogella.android.locationapi.maps-2.apk"],nativelibrarydirectories=[/data/app-lib/com.vogella.android.locationapi.maps-2, /vendor/lib, /system/lib]] 01-01 22:15:50.133: e/androidruntime(13111): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:53) 01-01 22:15:50.133: e/androidruntime(13111): @ java.lang.classloader.loadclass(classloader.java:501) 01-01 22:15:50.133: e/androidruntime(13111): @ java.lang.classloader.loadclass(classloader.java:461) 01-01 22:15:50.133: e/androidruntime(13111): @ android.app.instrumentation.newactivity(instrumentation.java:1054) 01-01 22:15:50.133: e/androidruntime(13111): @ android.app.activitythread.performlaunchactivity(activitythread.java:2260) 01-01 22:15:50.133: e/androidruntime(13111): ... 11 more 01-01 22:15:50.184: e/apperrordialog(494): failed ilowstoragehandle instance 01-01 22:16:50.897: e/playeventlogger(11433): upload failed class java.net.unknownhostexception(unable resolve host "play.googleapis.com": no address associated hostname) 01-01 22:17:17.911: e/celllocation(861): create gsmcelllocation 01-01 22:17:17.915: e/celllocation(861): create gsmcelllocation 01-01 22:17:32.905: e/celllocation(861): create gsmcelllocation 01-01 22:17:32.909: e/celllocation(861): create gsmcelllocation
try adding child of element:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
Comments
Post a Comment