Application of Google map on the Development Board

Source: Internet
Author: User
Tags certificate fingerprint

It's okay. I 've been playing with the company's development board. One day I wanted to integrate Google Maps, so I started to take action. The process is summarized into the following steps:

1. Create a project named GoogleMap Based on Google APIs

The content of several important engineering documents is as follows:

1) Layout file main. xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:orientation="vertical" >   <com.google.android.maps.MapView       android:id="@+id/map_view"       android:layout_width="fill_parent"       android:layout_height="fill_parent"       android:clickable="true"       android:apiKey="0vcWNfFdVG-uJZSMXPL0BnGQGlBYAxTs3frQpfQ"       /></LinearLayout>

There are two points to note:

I. mapview: similar to other views in the android SDK, the difference is that the view is not included in the SDK and is located in another jar package provided by Google. The full name of this jar package is com. google. android. maps. jar.

Ii. Android. apikey: apply online.

2) androidmanifest. xml file

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.raycommtech.googlemap"    android:versionCode="1"    android:versionName="1.0" >    <uses-sdk android:minSdkVersion="10" />    <uses-permission android:name="android.permission.INTERNET"/>    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>    <application        android:icon="@drawable/ic_launcher"        android:label="@string/app_name"        android:theme="@android:style/Theme.NoTitleBar.Fullscreen">        <uses-library android:name="com.google.android.maps"/>        <activity            android:label="@string/app_name"            android:name=".GoogleMapActivity" >            <intent-filter >                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application></manifest>

There are three areas to describe

I. Android: the default value of minsdkversion is 14. The system on the board is 2.3.7, And the API level is 10. Therefore, you must change it to the API level of the target board system. Otherwise, the following error is reported during running:

[2012-02-22 13:05:56 - GoogleMap] ERROR: Application requires API version 14. Device API version is 10 (Android 2.3.7).[2012-02-22 13:05:56 - GoogleMap] Launch canceled!

Ii. You need to add three uses-permission: Internet, access_coarse_location, access_fine_location

Iii. use external library: Use uses-library to indicate that the COM. Google. Android. Maps. Jar library containing mapview is used.

3) googlemapactivity. Java File

package com.raycommtech.googlemap;import com.google.android.maps.MapActivity;import com.google.android.maps.MapView;import android.os.Bundle;public class GoogleMapActivity extends MapActivity {private MapView mMapView = null;    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);                setContentView(R.layout.main);                        mMapView = (MapView)findViewById(R.id.map_view);        mMapView.setSatellite(false);        mMapView.setTraffic(true);        mMapView.setBuiltInZoomControls(true);    }@Overrideprotected boolean isRouteDisplayed() {return false;}}

2. Application for apikey

Run the following command on Ubuntu:

$cd ~$keytool -list -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android

The output on the terminal generates the following results:

Androiddebugkey, Mar 3, 2011, privatekeyentry,
Certificate fingerprint (MD5): E0: D1: 06: 6f: Be: 4d: 33: 1c: 3f: E6: C2: 9C: 49: E8: 2f: 1A

Add the required apikey generated from the generated MD5 fingerprint input connection to Android: apikey of mapview.

3. Deployment of programs on the Development Board and solutions to problems

Run the program directly. The following error is reported on the eclipse console:

[2012-02-22 13:06:32 - GoogleMap] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY[2012-02-22 13:06:32 - GoogleMap] Please check logcat output for more details.[2012-02-22 13:06:32 - GoogleMap] Launch canceled!

The detailed error is as follows through ADB logcat;

D/PackageParser( 1068): Scanning package: /data/app/vmdl583239231.tmpD/PackageManager( 1068): Scanning package com.raycommtech.googlemapE/PackageManager( 1068): Package com.raycommtech.googlemap requires unavailable shared library com.google.android.maps; failing!W/PackageManager( 1068): Package couldn't be installed in /data/app/com.raycommtech.googlemap-1.apk

The error message is obvious. The system on the Board does not have the shared library com. Google. Android. Maps. jar. Go to the android SDK's add-onsq/addon-google_apis-google_inc _-14/libs/directory to find the maps. jar, and re-run it as COM. google. android. maps. jar, push to the system using the following command:

$adb remount$adb push com.google.android.maps.jar /system/framework/

Restart the system, run the program, or report the following error. Obviously, the added database does not work. Google checked it and found that a COM. google. android. maps. XML permissions file with the following content:

<?xml version="1.0" encoding="utf-8"?><permissions>    <library name="com.google.android.maps"             file="/system/framework/com.google.android.maps.jar" /></permissions>

Run the following command to push the com. Google. Android. Maps. xml file to the system:

$adb remount$adb push com.google.android.maps.jar /system/etc/permissions/

Restart the system and run the program. The following error is reported:

E/AndroidRuntime( 1340): FATAL EXCEPTION: mainE/AndroidRuntime( 1340): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.raycommtech.googlemap/com.raycommtech.googlemap.GoogleMapActivity}: java.lang.ClassNotFoundException: com.raycommtech.googlemap.GoogleMapActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.raycommtech.googlemap-2.apk]E/AndroidRuntime( 1340): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)E/AndroidRuntime( 1340): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)E/AndroidRuntime( 1340): at android.app.ActivityThread.access$1500(ActivityThread.java:117)E/AndroidRuntime( 1340): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)E/AndroidRuntime( 1340): at android.os.Handler.dispatchMessage(Handler.java:99)E/AndroidRuntime( 1340): at android.os.Looper.loop(Looper.java:130)E/AndroidRuntime( 1340): at android.app.ActivityThread.main(ActivityThread.java:3683)E/AndroidRuntime( 1340): at java.lang.reflect.Method.invokeNative(Native Method)E/AndroidRuntime( 1340): at java.lang.reflect.Method.invoke(Method.java:507)E/AndroidRuntime( 1340): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)E/AndroidRuntime( 1340): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)E/AndroidRuntime( 1340): at dalvik.system.NativeStart.main(Native Method)E/AndroidRuntime( 1340): Caused by: java.lang.ClassNotFoundException: com.raycommtech.googlemap.GoogleMapActivity in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.raycommtech.googlemap-2.apk]E/AndroidRuntime( 1340): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)E/AndroidRuntime( 1340): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)E/AndroidRuntime( 1340): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)E/AndroidRuntime( 1340): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)E/AndroidRuntime( 1340): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)E/AndroidRuntime( 1340): ... 11 moreW/ActivityManager( 1065):   Force finishing activity com.raycommtech.googlemap/.GoogleMapActivity

Obviously, maps in the android SDK are not powerful, and mapactivity is required by wood. Therefore, you can only search for the desired file on the internet, download the file, and follow the steps above. google. android. maps. jar and COM. google. android. maps. push XML to the system, restart the Development Board, and execute the program as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.