Eclipse에서 에뮬레이터를 사용하여 Android에서 처음 Google지도를 만들려고합니다. 성공하지 못했습니다. 내가지도를 얻으려면 확대 할 수있는 회색 타일로 된 화면이 있지만 거기에는지도가 없습니다. 다음은 Google지도를 표시 할 수 없습니다
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.herb2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="17" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="com.example.herb2.Herb2Activity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my key is not shown here" />
</manifest>
내 레이아웃 파일 : 나는 그것을 함께 할 수있는 뭔가가있을 수 있습니다 의심하고
public class Herb2Activity extends MapActivity {
private TextView latitudeView;
private TextView longitudeView;
private LocationManager locationManager;
private MapController mapController;
private MapView mapView;
private GeoPoint point;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_herb2);
latitudeView = (TextView) findViewById(R.id.latitude_view);
longitudeView = (TextView) findViewById(R.id.longitude_view);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
mapView = (MapView) findViewById(R.id.mapvw);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
mapController = mapView.getController();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
3600, 1000, new LocationListener() {
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
}
public void onLocationChanged(Location loc) {
if (loc != null) {
int lt = (int) (loc.getLatitude());
int lg = (int) (loc.getLongitude());
latitudeView.setText("Latitude is: "
+ String.valueOf(lt));
longitudeView.setText("Longitude is: "
+ String.valueOf(lg));
int latit = (int) (loc.getLatitude() * 1E6);
int longit = (int) (loc.getLongitude() * 1E6);
point = new GeoPoint(latit, longit);
mapController.animateTo(point);
mapController.setZoom(15);
}
}
});
}
@Override
protected boolean isRouteDisplayed() {
return true;
}
@Override
protected boolean isLocationDisplayed() {
return false;
}
}
: 마지막으로 아래
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<TextView
android:id="@+id/latitude_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Latitude: " />
<TextView
android:id="@+id/longitude_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Longitude: " />
<com.google.android.maps.MapView
android:id="@+id/mapvw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:apiKey="my key is not shown here"
android:clickable="true"
android:enabled="true" />
</LinearLayout>
내 자바 소스입니다 아래 내 AndroidManifest
파일입니다 Google에서 생성 한 내 API 키입니다. 내 키를 생성하기 위해 SHA1 인증서 지문을 제공했습니다. 위의 그림과 같이 com.example.herb2
키의 끝에 패키지 이름을 추가했습니다. 또한 에뮬레이터로 Google API 장치를 사용하고 있는지 확인했습니다. MD5 지문을 생산 용으로 사용한다고 가정합니다. 내지도가 왜 회색을 보여 주는지에 대한 도움을 주시면 감사하겠습니다.
대부분의 경우 API 키에 문제가 있습니다. 귀하의 logcat이 인증 실패와 관련하여 아무 말도하지 않습니까? – Barney
다음과 같은 메시지가 표시됩니다. System : err-IOException : 맵 API 키가 잘못되어 서버가 logcat에서 3을 반환했습니다. – Calvin
logcat에는 아무런 오류가 없었습니다. 단지 경고였습니다. 나는 그것이 api 열쇠라고 생각한다. 키 생성에 대한 지침을 따르고 MD5 지문이 아닌 SHA1 지문을 사용했습니다. 내 지문을 입력 할 때 위에서 볼 수 있듯이 "com.example.herb2"라는 세미콜론과 패키지 이름을 사용했습니다. 내가 다른 열쇠를 만들어야한다고 생각하니? – Dave