gpt4 book ai didi

java - Android 版 Google map 签名流程

转载 作者:行者123 更新时间:2023-12-01 13:40:58 25 4
gpt4 key购买 nike

首先要做的事情。我在显示 map 时遇到了很多麻烦。我的意思是我已经遵循了多个教程,包括 Google Maps V2 简介 here 。我在某处读到我无法在模拟器上测试 map (在其他地方我需要另一种自定义模拟器),所以我的过程一直是不断使用 dropbox 在我自己的手机上安装应用程序。这可能是相关的,因为我刚刚读过 here map 发挥作用的唯一方式是通过 Google Play 商店对其进行签名和安装。

更重要的是,当我查看应用程序时,我看到的是带有缩放控件的空 map 。我在好几个地方读到这似乎是签名问题。我重读了整个过程,在尝试了几乎所有可能性之后,我知道我必须首先确切地知道我在做什么。

据我了解,有两种方法可以让应用程序正常工作:调试或测试和发布。我已经使用两个 keystore 签署了应用程序,并将它们添加到 Google API 控制台,如教程中所述。两种尝试都会产生相同的结果:带有缩放控件的空 map 。

我要说的是:关于整个过程,存在大量(即使不是矛盾的)模糊信息。

更新

它现在正在工作,我现在知道为什么了。我将分享我的相关文件,以防它可以帮助其他人。这些文件是来自 here 的精确复制粘贴(减去相关的包名称)。 .

MainActivity.java

package com.taveras.androidmapsv2;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends Activity {

// Google Map
private GoogleMap googleMap;

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

try {
// Loading map
initilizeMap();

} catch (Exception e) {
e.printStackTrace();
}

}

/**
* function to load map. If map is not created it will create it for you
* */
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();

// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}

@Override
protected void onResume() {
super.onResume();
initilizeMap();
}

}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

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

</RelativeLayout>

AndroidManifest

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

<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="18" />
<permission
android:name="com.taveras.androidmapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.taveras.androidmapsv2.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.taveras.androidmapsv2.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"
/>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDLKtTtTDxULNBvNLtGPvkEf6NNacs-42A" />
</application>

</manifest>

提前感谢您提供任何线索。虾仓鼠

最佳答案

抱歉,由于代表较低,目前无法发表评论,此 link当我第一次开始使用 Google map V2 时,它对我帮助很大。它拥有您入门所需的一切以及获取 api key 。

正如您所读到的,通常空白 map 是签名过程的问题。尝试点击链接,它非常详细。

据我所知,您可以在模拟器上运行谷歌地图,这里有很多关于此事的线程。 (例如 this 线程)

关于java - Android 版 Google map 签名流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20780085/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com