【问题标题】:While Make sign APK of Google map (Failed to load map Could not contact Google servers) this error accured虽然制作谷歌地图的签名APK(加载地图失败,无法联系谷歌服务器)这个错误发生了
【发布时间】:2013-04-16 13:57:15
【问题描述】:

在我的应用程序中,我将实现 Google 地图示例

但是:

  1. 当我直接运行应用程序时,地图将完美运行
  2. 虽然我可以制作签名 apk(制作密钥存储文件并与密钥存储 Apk 相关),但地图将无法工作

对于这个问题,我尝试了很多类似的想法

  1. 为我的应用程序创建另一个和另一个与包相关的 API KEY
  2. 在 Android Manifest 文件中添加额外权限(最新的 Manifest 权限如下)

有人可以帮忙吗?

<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>

我的 XML 布局包含这个
我给予谷歌地图示例中需要的所有权限

我的清单文件:

<?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>

【问题讨论】:

  • 一个问题是准确的,而我正在触发我的应用程序的签名 apk 文件
  • 请确保您使用 RELEASE 密钥来获取 GoogleMaps API 密钥。
  • 拳头我把 SHA1 KEY 然后 (;) 然后像 (org.Infoware.GuideBook3) 这样的包名称但是当我制作签名 apk 时,谷歌地图不起作用..并在 logcat 中显示错误“无法连接到谷歌地图”

标签: android google-maps google-maps-api-2


【解决方案1】:

制作 Google Map API 第 2 版的步骤

1)为您的签名密钥创建 SHA-1。

可以在 userhome/.android/debug.keystore 文件中找到用于签署应用程序的 Eclipse 调试密钥。 例如)C:\Users\nil pc43.android\debug.keystore

    ----->  C:\Program Files\Java\jdk1.7.0_01\bin\keytool.exe -v -list -alias androiddebugkey -keystore "C:\Users\Info 1234\.android\debug.keystore" -storepass     
android -keypass android


    Example)
        C:\Program Files\Java\jdk1.7.0_01\bin>keytool.exe -v -list -alias androiddebugkey -keystore "c:\Users\nil pc43\.android\deb
        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)在 Google API 控制台注册

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

3)为您的应用创建密钥

-----> 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)根据以下链接更改您的 Manifist.xml 和 JAVA 文件

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

5) 现在为您的项目创建新的 KeyStore 文件和 APK 文件。

----->C:\Program Files\Java\jdk1.7.0_01\bin>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)现在您将获得新的谷歌地图 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) 现在使用现有的密钥库为您的应用创建新的 APK 文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多