简体   繁体   中英

Google Maps doesn't show

Anybody knows, why my google Maps is not showing? I just can see the View, the "Google"-Logo and the zoom-Buttons:

map.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.google.android.gms.maps.MapView
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

MapClass:

    private View view = null;
private Context context;
private MapView mapView;
private Bundle mapBundle;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mapBundle = savedInstanceState;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    view = inflater
            .inflate(R.layout.fragment_map, container, false);

    String title = getResources().getString(R.string.MapTitle);
    String subtitle = getResources().getString(R.string.MapSubtitle);

    EventBus.getDefault().post(
            new RefreshActionBarEvent(ActionBarType.BACK,title,subtitle));

    context = view.getContext();

    MapsInitializer.initialize(getActivity());

    mapView = (MapView) view.findViewById(R.id.map);
    mapView.onCreate(mapBundle);
    GoogleMap map = ((MapView) view.findViewById(R.id.map)).getMap();
    return view;
}

@Override
public void onResume() {
    super.onResume();
    mapView.onResume();
}

@Override
public void onPause() {
    super.onPause();
    mapView.onPause();
}

@Override
public void onDestroy() {
    mapView.onDestroy();
    super.onDestroy();
}

In my Manifest.xml:

<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="AIzaSyBLS0IqFRti-R6LxbAr4X_KhkF0LWEWajg" />
</application>

<uses-permission android:name="android.permission.INTERNET" />
<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" />

I'm getting "Failed to find provider info for com.google.android.gsf.gservices" as output in my Logcat. Can someone help? Thanks :)

This is the correct Android_manifest.xml for displaying maps

<?xml version="1.0" encoding="utf-8"?>
<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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" />

<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.package.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>
<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="**Replace with your key**" />

Dont forget to add google-play-services_lib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM