我正在尝试在我的应用程序中实现Google地图,我已将这样的代码分段:
map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
MapsInitializer.initialize(getActivity());
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());
if(resultCode != ConnectionResult.SUCCESS)
{
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, getActivity(),
69);
dialog.setCancelable(false);
// dialog.setOnDismissListener(getOnDismissListener());
dialog.show();
}
Log.d("GooglePlayServicesUtil Check", "Result is: " + resultCode);
}
和我的XML:
<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">
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:apiKey="AIzaSyABcmhLoZuEuU6eMSlwWGA1_IrEKR3L5n8"
/>
</RelativeLayout>
当应用程序运行时,我可以看到地图边框和Zoomin / Zoomout按钮,但我得到2个错误,第一个
Could not find class 'com.google.android.gms.location.internal.ParcelableGeofence
referenced from method glt.a
几秒钟后我收到此错误:
Failed to load map. Error contacting Google servers. This is probably an
authentication issue (but could be due to network errors).
我刚刚通过Eclipse的Windows,首选项,Android,Build,SHA1指纹和在Google创建的SHA1指纹重新获得了我的关键:
API Project / APIS & AUTH / Credentials / Create New Key / Android Key
像这样:
2A:61:79:6F:3D:41:9E:C9:81:F5:C0:49:EE:F8:CA:09:04:0C:3A:AE;com.lifemate.lmmessenger.mapspack
(我的班级是com.lifemate.lmmessenger.mapspack.maps),这是我的清单:
<uses-permission
android:name="com.lifemate.lmmessenger.mapspack.maps.permission.MAPS_RECEIVE"/>
<IS THE UPPER ONE RIGHT? (My Class is the maps.Java>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<Application ...
<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="AIzaSyABcmhLoZuEuU6eMSlwWGA1_IrEKR3L5n8" />
我已将Google Play服务Jar和项目添加到我的应用程序中,我是否遗漏了某些人?
答案 0 :(得分:0)
如果您使用带有命名空间的Android Key,则必须使用已签名的应用程序(使用密钥生成apk)
如果您使用应用程序进行测试,只需将其删除并留空:
2A:61:79:6F:3D:41:9E:C9:81:F5:C0:49:EE:F8:CA:09:04:0C:3A:AE;com.lifemate.lmmessenger.mapspack