0

I am a newbie to android Google maps, I followed some tutorial to begin, I am getting error. I am unable to see google map on emulator(samsung galaxy 2), I wrote all the code below, please help me with the error.

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examp.onemap"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="7"
    android:targetSdkVersion="18" />
<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"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.examp.onemap.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>
    <uses-library android:name="com.google.android.maps" />
</application>

</manifest>

MainActivity.java

package com.examp.onemap;

import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class MainActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);   
    MapView mapView = (MapView) findViewById(R.id.mapView);
    mapView.setBuiltInZoomControls(true);
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}

}

I generated key from`https://code.google.com/apis/console/

main.xml

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="AIzaSyDXwNWYXS9Lz9d-bJlodc1GELulHsalkT0"/>
sree7k7
  • 17
  • 9

3 Answers3

0

First of all you are mixing both Google Maps API's. You are trying to use Google Maps API V1 objects and code with as it would seem an API V2 key. This will never work. So what you need to do first is to change you code to an API V2 code. You can follow this tutorial I wrote to do that:

Google Maps API V2

Now even if you change your code to an API V2 code this will still not work on the emulator, as you can't run the Google Maps API V2 on the emulator without installing the Google Play Services API first.

Emil Adz
  • 40,709
  • 36
  • 140
  • 187
  • Thanks for your replay. I installed google play services but, I am still getting error in main.xml @xmlns:map="http://schemas.android.com/apk/res-auto" in fragment. – sree7k7 Aug 30 '13 at 12:24
  • You can try to remove this line if you don't use any other map attributes on the fragment component in the xml file. What happens when you check the application on a real device? – Emil Adz Aug 30 '13 at 14:48
  • I removed the line. I executed this application in galaxy s2. I got a white colored background view with zoom functions but I couldn't see the map..:( – sree7k7 Aug 30 '13 at 16:45
  • you have not followed the tutorial I have provided you and you are using the wrong objects in you xml file and the java file. Use the tutorial that I have give to use the Google Maps API V2. – Emil Adz Aug 30 '13 at 17:56
  • I followed your tutorial once again from [link]https://blog-emildesign.rhcloud.com/?p=403 and [link]http://blog-emildesign.rhcloud.com/?p=435 . Still I am facing problem with main.xml error. I am using ADT bundle on windows 8. I don't know what to do. – sree7k7 Aug 30 '13 at 22:11
  • I didn't get you. what you mean accept/upvote, and how to do? – sree7k7 Aug 31 '13 at 21:08
  • Thanks man, I did. can you please help me more about navigation to a particular location by using latitude and longitude. – sree7k7 Aug 31 '13 at 21:15
  • Thanks for your blog. I am getting few errors in this code. Can you explain me how to use this code. I need to create each class or else i need to need to put the total code in GMapV2Direction class. – sree7k7 Sep 03 '13 at 17:44
  • you will need to create two classes, one for the GMapV2Direction and the other one for the AsyncTask. finally there are two methods to implement in your Maps Activity. – Emil Adz Sep 03 '13 at 17:54
  • Thanks for your replay. I will check. I think, there i no need of modification of GMapV2Direction and AsyncTask. – sree7k7 Sep 03 '13 at 17:58
  • I am still getting errors. Under **src** folder I have created MainActivity.java, GMapV2Direction.java, AsyncTask.java. In a AsyncTask.java I kept step 2 code. Is this a right way of fetching your code. – sree7k7 Sep 03 '13 at 18:28
  • I am getting error in GMapV2Direction at 107 line of your code. later I created GetDirectionsAsyncTask.java under src, in this i am getting lot of errors. I am bit confusing how to use the code actually. – sree7k7 Sep 03 '13 at 21:55
  • could paste the exact lines of code on which you having errors? – Emil Adz Sep 04 '13 at 10:42
  • for(int j = 0 ; j < arr.size() ; j++) { listGeopoints.add(new LatLng(arr.get(j).latitude, arr.get(j).longitude)); } – sree7k7 Sep 06 '13 at 11:17
0

Codings are Google map v1. Switch over to Google map v2.

Documentations are here

https://developers.google.com/maps/documentation/android/start

Tutorials are

http://www.vogella.com/articles/AndroidGoogleMaps/article.html

Shadow
  • 6,864
  • 6
  • 44
  • 93
0

If you have changed it to V2, this can help you :

Running Google Maps v2 on the Android emulator

Hopefully ;)

Community
  • 1
  • 1
silvia_aut
  • 1,481
  • 6
  • 19
  • 33