Google Maps Android API v2 tutorial -


i'm working on tutorial google maps android api v2 @ : https://developers.google.com/maps/documentation/android/start

i'm trying simple map shown in app, yet it's not working (the app doesn't open, , there's message box "the "test2" application has stopped.") , don't know why. followed said in tutorial.

here's code :

androidmanifest.xml :

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.test2"     android:versioncode="1"     android:versionname="1.0" >      <uses-sdk         android:minsdkversion="8"         android:targetsdkversion="17" />      <permission         android:name="com.example.test2.permission.maps_receive"         android:protectionlevel="signature"/>      <uses-permission android:name="com.example.test2.permission.maps_receive"/>     <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"/>      <uses-permission android:name="android.permission.access_coarse_location"/>     <uses-permission android:name="android.permission.access_fine_location"/>      <uses-feature         android:glesversion="0x00020000"         android:required="true"/>      <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >          <activity             android:name="com.example.test2.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="the key"/>     </application>  </manifest> 

activity_main.xml :

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

mainactivity.java :

package com.example.test2;  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;     } } 

thank in advance.

edit :

here's logcat :

04-09 11:58:31.689: e/androidruntime(4028): fatal exception: main 04-09 11:58:31.689: e/androidruntime(4028): java.lang.runtimeexception: unable start activity componentinfo{com.example.test2/com.example.test2.mainactivity}: android.view.inflateexception: binary xml file line #1: error inflating class fragment 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2059) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2084) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activitythread.access$600(activitythread.java:130) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activitythread$h.handlemessage(activitythread.java:1195) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.os.handler.dispatchmessage(handler.java:99) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.os.looper.loop(looper.java:137) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activitythread.main(activitythread.java:4745) 04-09 11:58:31.689: e/androidruntime(4028):     @ java.lang.reflect.method.invokenative(native method) 04-09 11:58:31.689: e/androidruntime(4028):     @ java.lang.reflect.method.invoke(method.java:511) 04-09 11:58:31.689: e/androidruntime(4028):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:786) 04-09 11:58:31.689: e/androidruntime(4028):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) 04-09 11:58:31.689: e/androidruntime(4028):     @ dalvik.system.nativestart.main(native method) 04-09 11:58:31.689: e/androidruntime(4028): caused by: android.view.inflateexception: binary xml file line #1: error inflating class fragment 04-09 11:58:31.689: e/androidruntime(4028):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:704) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.view.layoutinflater.inflate(layoutinflater.java:466) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.view.layoutinflater.inflate(layoutinflater.java:396) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.view.layoutinflater.inflate(layoutinflater.java:352) 04-09 11:58:31.689: e/androidruntime(4028):     @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:256) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activity.setcontentview(activity.java:1867) 04-09 11:58:31.689: e/androidruntime(4028):     @ com.example.test2.mainactivity.oncreate(mainactivity.java:12) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activity.performcreate(activity.java:5008) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1079) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2023) 04-09 11:58:31.689: e/androidruntime(4028):     ... 11 more 04-09 11:58:31.689: e/androidruntime(4028): caused by: android.app.fragment$instantiationexception: unable instantiate fragment com.google.android.gms.maps.supportmapfragment: make sure class name exists, public, , has empty constructor public 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.fragment.instantiate(fragment.java:584) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.fragment.instantiate(fragment.java:552) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.activity.oncreateview(activity.java:4656) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:680) 04-09 11:58:31.689: e/androidruntime(4028):     ... 20 more 04-09 11:58:31.689: e/androidruntime(4028): caused by: java.lang.classnotfoundexception: com.google.android.gms.maps.supportmapfragment 04-09 11:58:31.689: e/androidruntime(4028):     @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:61) 04-09 11:58:31.689: e/androidruntime(4028):     @ java.lang.classloader.loadclass(classloader.java:501) 04-09 11:58:31.689: e/androidruntime(4028):     @ java.lang.classloader.loadclass(classloader.java:461) 04-09 11:58:31.689: e/androidruntime(4028):     @ android.app.fragment.instantiate(fragment.java:574) 04-09 11:58:31.689: e/androidruntime(4028):     ... 23 more 

the problem see here line:

 <uses-library android:name="com.google.android.maps" /> 

this line belong google map api v1 , shouldn't written in google map api v2.

we can't more without logcat output.

update:

if pasted right manifest file current problem is:

1. developing application min sdk 8 have use supportmapfragment instead of mapfragment object in xml layout file of activity. this:

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

you can take @ blog post wrote on how add google map api v2 application:

google map api v2


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" -