Tôi đang cố gắng phát hành ứng dụng của mình nhưng gặp sự cố với bản đồ google. Ứng dụng có chứa hoạt động (MapActivity) hiển thị bản đồ. Khi chạy trong chế độ gỡ lỗi, bản đồ hoạt động tốt. Tôi đã ký ứng dụng của mình ở chế độ phát hành và nhận được SHA1. Tôi đã tạo một khóa android mới trên bảng điều khiển của Google theo yêu cầu (SHA1; packageName). Có khóa APIBản đồ của Google không hiển thị trên Android ở chế độ phát hành
Trong ứng dụng của tôi, tôi đã tham chiếu bản sao của google-play-services-lib theo yêu cầu. Tôi đang sử dụng 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
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
<?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>
Điều duy nhất kỳ lạ là khi tôi sử dụng keytool để có được SHA1 tôi nhận được " Tên thuật toán chữ ký: SHA256withRSA, đây có phải là vấn đề không? Nếu có, làm thế nào tôi có thể thay đổi?
Tôi bị kẹt ở đây! Cảm ơn bạn đã giúp đỡ!
điều này có thể giúp http://stackoverflow.com/questions/13696620/google-maps-android-api-v2-authorization-failure – Waqas
Thử tạo lại khóa phát hành của bạn: http://chocotech.blogspot.com/2012 /10/get-debug-key-and-release-key-for.html – svlzx
https://stackoverflow.com/a/46418176/2898708 –