Reputation: 9
this is the last code of project. i follow all of your steps https://blog-emildesign.rhcloud.com/?p=435 but my app is stopped.
main.java
package com.example.halkbank;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.support.v4.app.FragmentActivity;
public class GoogleMaps extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_google_maps);
}
}
main.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=".GoogleMaps" >
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent" />
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.halkbank"
android:theme="@android:style/Theme.NoTitleBar"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission android:name="com.example.halkbank.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.example.halkbank.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" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.halkbank.GoogleMaps"
android:label="@string/title_activity_google_maps"
android:theme="@android:style/Theme.NoTitleBar" >
<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="api key" />
</application>
</manifest>
and printscreens of my libraries
http://s22.postimg.org/66m62oxk1/image.png
what do you mean?? where is my mistake??
Upvotes: 0
Views: 852
Reputation: 41099
You are trying to use both version of the Google Maps API. While you are using the android-support
library and google-play-services
library that are required for API V2
in you code you are using API V1
.
I guess that this is the reason you don't see a map, you probably produces a key for API V2
and trying to use in API V1
.
The first thing you should do is to move your code to API V2
as API V1
as been already said is deprecated and outdated.
Now to be more clear this means that you will have to remove this:
<uses-library android:name="com.google.android.maps" />
as it belongs to API V1.
Next you will have to get a new API V2 key, if you haven't already did so, you can use this guide to do this:
and then change your java code from MapActivity
and MapView
code to a simple Activity
or FragmentActivty
and MapFragment
or SupportMapFragment
respectivly depending for which platform you develop your application, you can get an idea how to start using this guide:
You forgot to change the name of the activity in your manifest file from:
<activity
android:name="com.example.halkmaps.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
To:
<activity
android:name="com.example.halkmaps.GoogleMaps"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 0
Reputation: 7037
Even though using a MapView
with an older API key should still work, it has been recently deprecated. (source)
You should be using the Google Maps Android API v2 which is added to applications with a MapFragment
. Read more about it in the documentation.
Try adding the map to your application according to the tutorial in the documentation and then ask a new question if that doesn't work.
Upvotes: 3