Change on eclipse.ini Xmx1024m !!!!
Google Maps API is supports API level 9 and up
This page describes how to set up the Google Maps Android API utility library with Eclipse, and to run the demo app included in the library.
For guidelines on setting up the Google Maps Android API utility library with Android Studio/Gradle or Maven, please refer to the library's website.
My remark ----> this library is for inhanced features and not a must !!!Prerequisites and notes
The Google Maps Android API utility library supports Android API level 9 and above. The animated re-clustering features are only available for Android API level 14 and above. When setting your project build target, make sure you use the latest Android API level.
Throughout the setup procedure described below, it's a good idea to clean and build the projects often, to make sure you don't try to fix errors that are already fixed. To be on the safe side, use Project > Clean > Clean all projects after each step. Also, make sure Project > Build Automatically is checked.
Install the Android SDK
Install the Android SDK. Note that the ADT Bundle includes a version of Eclipse with the Android Developer Tools (ADT) built in.
Get the Google Maps Android API utility library
Download the android-maps-utils repository. You can do it by cloning the repo (recommended, to receive automatic updates) or downloading a zip file. If you want to customize the library, you should fork the repo.
The repository includes:
- A demo application, in the
demo
directory. - The library of utilities, in the
library
directory. - Various files containing license, contributors, and readme information.
- Gradle build configuration, for use with Android Studio.
Import the utility library into Eclipse
Follow these steps to import the
demo
and library
directories from the utility library into Eclipse:- Choose File > Import > Android > Existing Android Code Into Workspace, and click Next.
- Browse to the location where you saved the Google Maps Android API Utility Library, select the option to Copy projects into workspace, and import the
demo
andlibrary
directories.
Hint: Eclipse will show errors on your project at this stage. Don't be discouraged. The next steps will fix the errors.
Import the Google Play services SDK
The Google Maps Android API is distributed as part of the Google Play services SDK. You can download the Google Play services SDK via the Android SDK Manager.
Here is a summary of the steps you will need to take:
- Install the Google Play services SDK and import it into Eclipse, as described in the Google Play services documentation.
- Mark Google Play services as a library: Right-click the google-play-services_lib project, and choose Properties > Android. Tick the Is Libraryoption.
- Follow the above steps to mark the utility library project as a library too.
- Reference the Google Play services library as a dependency for the utility library project: Right-click the library project and choose Properties > Android. Follow the steps in Referencing a Library Project.
Add the Android Support Library
Now you need to add the Android Support library to the utility library project:
- Right-click the library project and choose Android Tools > Add support library.
- Accept the license and install the library.
Run the utility demo app on your Android device
The utility library ships with a demo app that includes sample implementations of each utility. Follow these steps to run the demo app on your Android device.
Reference the utility library from the utility demo app
Add the utility library as a dependency of the utility demo app:
- Right-click the MainActivity project (this is the utility demo app) and chooseProperties > Java Build Path.
- Click the Projects tab and choose Add.
- Select the library project and click OK, then OK again.
I got memory problem running this Demo !!!!
Get an API key
To access the Google Maps servers with the Google Maps Android API, you need to add an API key to your application. The key is free, and it supports an unlimited number of users. To get a Maps API key, visit the Google Developers Console and provide the utility demo app's signing certificate and package name (
com.google.maps.android.utils.demo
).
Then add the API key to the utility demo app's
AndroidManifest.xml
file. Note that the demo app already has an API key in the manifest. You will need to replace the key with your own API key.
Detailed instructions are in the guide to API keys :
********************************************************************************
start guide to API keys
To use the Google Maps Android API, you must register your app project on the Google Developers Console and get a Google API key which you can add to your app. The type of API key you need is an Android key.
Overview
All Android apps are signed with a digital certificate for which you hold the private key. Refer to the Android guide to signing your applications for more information about digital certificates.
Android API keys are linked to specific certificate/package pairs. You only need one key for each certificate, no matter how many users you have for the app.
Getting a key for your app requires several steps. These steps are outlined below, and described in detail in the following sections.
- Get information about your app's certificate.
- Register a project in the Google Developers Console and add the Google Maps Android API as a service for the project.
- Create a key.
- Add the key to your app by adding an element to your app manifest.
Display your app's certificate information
The API key is based on a short form of your app's digital certificate, known as its SHA-1 fingerprint. To display the SHA-1 fingerprint for your certificate, first ensure that you are using the right certificate. You may have two certificates:
- A debug certificate: The Android SDK tools generate this certificate automatically when you do a debug build. Only use this certificate with apps that you're testing. Do not attempt to publish an app that's signed with a debug certificate. The debug certificate is described in more detail in Signing in Debug Mode in the Android Developer Documentation.
- A release certificate: The Android SDK tools generate this certificate when you do a release build. You can also generate this certificate using the
keytool
program. Use this certificate when you are ready to release your app to the world.
Follow the steps below to display a certificate's SHA-1 fingerprint using the
keytool
program with the -v
parameter. For more information about Keytool, see the Oracle documentation.Displaying the debug certificate fingerprint
- Locate your debug keystore file. The file name is
debug.keystore
, and is created the first time you build your project. By default, it is stored in the same directory as your Android Virtual Device (AVD) files:- OS X and Linux:
~/.android/
- Windows Vista and Windows 7:
C:\Users\your_user_name\.android\
If you are using Eclipse with ADT, and you're not sure where your debug keystore is located, you can select Windows > Prefs > Android > Build to check the full path. Notice that you can get SHA1 using Windows > Prefs > Android > Build - OS X and Linux:
- List the SHA-1 fingerprint:
- For Linux or OS X, open a terminal window and enter the following:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
- For Windows Vista and Windows 7, run:
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
You should see output similar to this:
Alias name: androiddebugkeyCreation date: Jan 01, 2013 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate[1]: Owner: CN=Android Debug, O=Android, C=USIssuer: CN=Android Debug, O=Android, C=USSerial number: 4aa9b300 Valid from: Mon Jan 01 08:04:04 UTC 2013 until: Mon Jan 01 18:04:04 PST 2033 Certificate fingerprints: MD5: AE:9F:95:D0:A6:86:89:BC:A8:70:BA:34:FF:6A:AC:F9 SHA1: BB:0D:AC:74:D3:21:E1:43:07:71:9B:62:90:AF:A1:66:6E:44:5D:75 Signature algorithm name: SHA1withRSA Version: 3
The line that begins with
SHA1
contains the certificate's SHA-1 fingerprint. The fingerprint is the sequence of 20 two-digit hexadecimal numbers separated by colons.Create an API project in the Google Developers Console
Follow these steps to create or modify a project for your application in the Google Developers Console and enable the Google Maps Android API.
If you want to be guided through the process and activate the Google Maps Android APIautomatically, click this link.
Alternatively, you can activate the Google Maps Android API yourself in the Developers Console by doing the following:
- Go to the Google Developers Console.
- Select a project, or create a new one.
- Open the API Library in the Google Developers Console. If prompted, select a project or create a new one. Select the Enabled APIs link in the API section to see a list of all your enabled APIs. Make sure that the API is on the list of enabled APIs. If you have not enabled it, select the API from the list of APIs, then select theEnable API button for the API. The only API you need is the Google Maps Android API, although you can choose to enable other APIs for the same project too.
Get an Android API key
Access your project's API keys and other credentials as follows:
- Go to the Google Developers Console.
- In the sidebar on the left, select Credentials.
- If your project doesn't already have an Android API key, create one now by selecting Add credentials > API key > Android key.
- In the resulting dialog, enter your app's SHA-1 fingerprint and package name. For example:
BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75
com.example.android.mapexample
- Your new Android API key appears in the list of API keys for your project. An API key is a string of characters, something like this:
AIzaSyBdVl-cTICSwYKrZ95SuvNw7dbMuDt1KG0
Add the API key to your application
Follow the steps below to include the API key in your application's manifest, contained in the file
AndroidManifest.xml
.- In
AndroidManifest.xml
, add the following element as a child of the<application>
element, by inserting it just before the closing</application>
tag:<meta-data android:name="com.google.android.geo.API_KEY" android:value="API_KEY"/>
Substitute your API key for API_KEY in thevalue
attribute. This element sets the keycom.google.android.geo.API_KEY
to the value of your API key. - Save
AndroidManifest.xml
and re-build your application.
Note: As shown above,
com.google.android.geo.API_KEY
is the recommended metadata name for the API key. A key with this name can be used to authenticate to multiple Google Maps-based APIs on the Android platform, including the Google Maps Android API. For backwards compatibility, the API also supports the name com.google.android.maps.v2.API_KEY
. This legacy name allows authentication to the Android Maps API v2 only. An application can specify only one of the API key metadata names. If both are specified, the API throws an exception.
end guide to API keys
*********************************************************************************
Run the demo app
If you haven't already done so, enable developer mode on the Android device. Then attach the Android device to your computer.
Right click the MainActivity project (this is the utility demo app) and choose Run As > Android Application.
The app should open on the Android device. You can also find it in your app list, under the name Maps Utils Demo.
This screenshot shows the app on an Nexus 4 device:
running it i get the :
References :Nathan
No comments:
Post a Comment