在android中使用发布密钥映射显示
作者:互联网
我已经为我的应用程序创建了Release键.但是它没有显示map.What我错了吗?我通过右击项目创建了释放键 – >导出 – >给alias_name-> …喜欢然后通过使用Keytool.,我得到了释放key.i在我的xml上使用它.
我的代码:
public class SampleMapActivity extends MapActivity {
MapView myMapView = null;
MapController myMC = null;
GeoPoint geoPoint = null;
double latitude = 12.937875, longitude = 77.622313;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myMapView = (MapView) findViewById(R.id.myGMap);
geoPoint = new GeoPoint((int) (latitude * 1000020), (int) (longitude * 1000020));
myMapView.setStreetView(true);
myMC = myMapView.getController();
myMC.setCenter(geoPoint);
myMC.setZoom(15);
myMapView.setBuiltInZoomControls(true);
myMapView.displayZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_I) {
myMapView.getController().setZoom(myMapView.getZoomLevel() + 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_O) {
myMapView.getController().setZoom(myMapView.getZoomLevel() - 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_S) {
myMapView.setSatellite(true);
return true;
} else if (keyCode == KeyEvent.KEYCODE_M) {
myMapView.setSatellite(false);
return true;
}
return false;
}
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/myGMap"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
android:clickable="true"
android:apiKey="0GNnbje3crS0ZuqJfAFnJjO8zNPYy9OqNzHS2Aw"
/>
</LinearLayout>
解决方法:
让我们去获取MapAPIKey.
1)如何创建KeyStore
Project >> Export >> ExportAndroidApplication >> Next >> Create New Keystore (Remember Keystore Path) >> Fill All Detail >> ...etc
现在您的密钥库和Apk已创建.
2)如何获得证书指纹(MD5)
$keytool -list -alias alias_name -keystore my-release-key.keystore
了解更多细节go here
现在你有像指纹一样的指纹
证书指纹(MD5):94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98
3)如何获得MapApiKey
click here并粘贴您的MD5然后您将获得MapAPIKey.
在您的应用程序中使用此密钥.
4)测试
使用此密钥库创建新的apk并检查..
标签:android-maps,android 来源: https://codeday.me/bug/20191001/1837386.html