Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
188 views
in Technique[技术] by (71.8m points)

android - While Make sign APK of Google map (Failed to load map Could not contact Google servers) this error accured

In my application I will implement Google Maps example

However:

  1. When I directly run the application the map will run perfectly
  2. While I can make sign apk (make Key Store file and related to key Store Apk) then the map will not work

For this problem I am tried so many ideas like

  1. Create an another and another API KEY of my app related to package
  2. Put extra permission in Android Manifest File (latest Manifest permission are given below)

Can someone help?

<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"
tools:context=".CountryRequirement" >

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.MapFragment" />

</RelativeLayout>

My XML Layout contain this
I giving all permission that will need in Google Maps example

My manifest file:

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="14" />

    <permission
        android:name="org.Infoware.GuideBook3.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="org.Infoware.GuideBook3.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-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon_72"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name="org.Infoware.GuideBook3.GuideBook3"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
              <activity android:name=".CountryRequirement" >
        </activity>


        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyCRZ_GAcbSqWDgghfSJ26HcPmS0kXB6a5s" />
    </application>

</manifest>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Step for Making Google Map API Version 2

1)Creating the SHA-1 for your signature key.

The Eclipse debug key for signing your application can be found in the userhome/.android/debug.keystore file. eg) C:Users il pc43.androiddebug.keystore

    ----->  C:Program FilesJavajdk1.7.0_01inkeytool.exe -v -list -alias androiddebugkey -keystore "C:UsersInfo 1234.androiddebug.keystore" -storepass     
android -keypass android


    Example)
        C:Program FilesJavajdk1.7.0_01in>keytool.exe -v -list -alias androiddebugkey -keystore "c:Users
il pc43.androiddeb
        ug.keystore" -storepass android -keypass android
        Alias name: androiddebugkey
        Creation date: Apr 4, 2013
        Entry type: PrivateKeyEntry
        Certificate chain length: 1
        Certificate[1]:
        Owner: CN=Android Debug, O=Android, C=US
        Issuer: CN=Android Debug, O=Android, C=US
        Serial number: 4a5b5c6d
                Valid from: Thu Apr 04 18:33:13 IST 2013 until: Sat Mar 28 18:33:13 IST 2043
        Certificate fingerprints:
                 MD5:  51:CE:5C:07:05:31:98:6A:D5:7C:24:B1:B3:EC:22:A3
                 SHA1: B2:68:A7:D6:3A:FC:8F:15:8D:3E:1F:4A:E8:99:CE:8D:F5:28:07:4D
                 SHA256: 5B:5B:FE:7B:92:7F:06:53:1E:28:BB:D0:E5:CB:05:46:B0:81:76:CC:61:87:97:FA:19:68:B6:C1:08:E8:D6:D9
                 Signature algorithm name: SHA256withRSA
                 Version: 3

2)Register with the Google APIs Console

-----> https://code.google.com/apis/console/
     ----> Go to Services 
Then Activate(ON) the Google Maps Android API v2. 

3)Create key for your application

-----> sELECT  API ACCESS
    **You need later to register your application via its package in this console together
    with the SHA-1 fingerprint of your signature key. For this you  select the entry and
    click on the API Access entry. Afterwards click on the Create new Android key...entry.**

-----> Click on "Create New Android KEY"
-----> Enter your SHA-1 fingerprint and the package of your application separated by a semicolon. 

       For example you can use the com.example.mymaps package. (your SHA-1 key;package Name)

4)Change Your Manifist.xml and JAVA File according below link

-----> please Reffer this Link
http://www.vogella.com/articles/AndroidGoogleMaps/article.html

5)Now Create new KeyStore File and APK file For your project.

----->C:Program FilesJavajdk1.7.0_01in>keytool -list -alias "your alias name" -keystore  "path that have keystor file of yor application"
    Enter keystore password: <pasword of your keystore>
    mapExample, Apr 18, 2013, PrivateKeyEntry,
    Certificate fingerprint (SHA1): 71:EF:B0:6A:A8:BG:E5:61:E9:23:D0:F2:1E:9D:D0:6F:A4:70:0F:A9

-----> Now you have new SHA-1 KEY 
-----> With this SHA-1 KEY, Follow the Step no 4

6)Now you will get NEW google map API KEY

Now use this key in to Manifeast.xml file (AS SHOWN IN STEM NO 4)

<meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="NEW GOOGLE MAP API KEY" />

7)Now Create New APK FILE of you APLICATION with the use the existing keystore.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...