Google Maps Api V2로 앱을 만들려고하지만 매번 줌 버튼이있는 빈 화면 만 있습니다. 나는 모든 것이 내 코드에 있다고 생각한다. 나는 필요한 모든 권한을 가지고, 나는 올바르게 열쇠를 가지고있다. 이미 debug.keystore를 다른 하나를 생성하기 위해 Eclipse를 삭제하지만, 여전히 줌 버튼과 동일한 빈 화면이 있습니다. 내 암호가 잘못되어 있으면 누구나 볼 수 있습니까?Google Maps Android API V2가있는 빈지도 만있는 이유는 무엇입니까?
내 매니페스트 :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.meu"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<permission
android:name="com.example.meu.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.meu.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" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="****My key here***" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".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>
</application>
내 레이아웃 :
<?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>
내 자바 코드 :
package com.example.meu;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import android.app.Activity;
import android.app.AlertDialog;
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);
try {
// Loading map
setContentView(R.layout.activity_main);
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();
}
나는 이미 많은 것을 읽었지만 아무도 나를 도울 수 없었다.
Try - public 클래스 MainActivity는 extends Activity 대신 FragmentActivity를 확장합니다. –
및 ((SupportMapFragment) getSupportFragmentManager(). findFragmentById (R.id.map)). getMap(); 대신에 (MapFragment) –
먼저, 고마워! 나는이 일을하지만 여전히 일하지 않는다. 그런 다음 minsdk를 8로 변경하고 대상을 20으로 변경하고 내 에뮬레이터 (안드로이드 4.3)에서 마침내 작동하지만 내 장치 (안드로이드 4.1.2)에서 동일한 빈지도가 있습니다. 이제 나는 혼란스러워. – Natan