谷歌地图不显示在释放模式在Android

谷歌地图不显示在释放模式在Android

本文介绍了谷歌地图不显示在释放模式在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想释放我的应用程序,但与谷歌地图的一个问题。
该应用程序包含一个显示地图的活动(MapActivity)。在调试模式下运行,在地图工作正常。
我签我在发布模式的应用程序,并得到了SHA1。
我根据需要创建(SHA1;的packageName)谷歌控制台上的一个新的Andr​​oid密钥。得到的API密钥

I am trying to release my app, but having a problem with google maps.The app contains an activity (MapActivity) that displays a map. When running in debug mode, the map works fine.I signed my app in release mode, and got SHA1.I created a new android key on Google console as required (SHA1;packageName). Got the API Key

在我的应用程序,我引用谷歌播放服务-lib中的副本作为必需的。
我使用的ADT。

In my App, I referenced a copy of google-play-services-lib as required.I am using ADT.

map.xml

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment" />

MapActivity.java

MapActivity.java

public class MapActivity extends FragmentActivity {

private GoogleMap map;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);

    map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                        .getMap();
  }

AndroidManifest.xml中

AndroidManifest.xml

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



<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

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

<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>

<permission
      android:name="com.example.rentalcar.permission.MAPS_RECEIVE"
      android:protectionLevel="signature"/>
    <uses-permission android:name="com.example.rentalcar.permission.MAPS_RECEIVE"/>


<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
     >

    <activity
        android:name="com.example.rentalcar.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    <activity
        android:name="com.example.rentalcar.MapActivity"
        android:label="@string/title_activity_map"
        android:screenOrientation="portrait" >
    </activity>

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

</application>

</manifest>

唯一奇怪的是,当我使用keytool获得SHA1我得到签名算法名:??SHA256withRSA可这是问题如果是的话,我该怎么改变它

The only weird thing is that when I use keytool to get SHA1 I get "Signature Algorithm name: SHA256withRSA. can this be the problem? If yes, how can I change it?

我有点坚持在这里!感谢您的帮助!

I am kind of stuck here! Thank you for any help!

推荐答案

在地图API V2,在一个发行版本和调试版本之间改变的事情是,你在这里注册的关键

in the map API V2, the ONLY thing that change between a release version and a debug version is the Key that you register here https://code.google.com/apis/console/

如果调试工作,并最终发布是不是,它是唯一的变化必要的。

If debug is working and final release is not, it's the only change necessary.

所以,我建议你仔细检查您的版本密钥存储的哈希值code,并确保它的正确输入对谷歌API控制台。

So I suggest you to double check the hash code of your release keystore and make sure that it's properly input on the Google API Console.

这篇关于谷歌地图不显示在释放模式在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 00:36