2017-12-09 4 views
0

私は今アンドロイドに表示グーグルマップを学んでいます。メインアクティビティでGoogleマップを表示するための非常に単純なアプリケーションです。Googleマップが唯一の場所の名前を表示し、アンドロイドでいないマップレイヤエミュレータ

地図表示は、実際のハードウェア(サムスンギャラクシーC5)には問題がありません。しかし、Androidエミュレータではマップレイヤーを表示できません。

私は、同じ結果をAPI 19、23および25を試してみました。スクリーンショットをご覧ください。誰でも知っている理由は?ありがとう。

Screenshot: map in api 23

Screenshot: error

ここに私のAndroidManifest.xml

ここ
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="com.example.zhongjiefan.mapsapp"> 

<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"/> 

<permission 
    android:name="com.example.zhongjiefan.mapsapp.permission.MAPS_RECEIVE" 
    android:protectionLevel="signature"/> 

<uses-permission android:name="com.example.zhongjiefan.mapsapp.permission.MAPS_RECEIVE" /> 
<uses-permission android:name="com.google.android.providers.gsf.permissions.READ_GSERVICES"/> 
<uses-feature android:glEsVersion="0x00020000" 
       android:required="true" /> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 
     <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.maps.v2.API_KEY" 
       android:value="--removed--"/> 

    <meta-data android:name="com.google.android.gms.version" 
       android:value="@integer/google_play_services_version"/> 
</application> 

</manifest> 

は私activity_main.xmlです:ここでは

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    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" 
    android:orientation="vertical" 
    android:padding="16dp" 
    tools:context="com.example.zhongjiefan.mapsapp.MainActivity"> 


    <fragment 
     android:id="@+id/mapFragment" 
     android:name="com.google.android.gms.maps.MapFragment" 
     android:layout_width="368dp" 
     android:layout_height="495dp" 
     android:layout_margin="8dp" 
     tools:layout_editor_absoluteY="8dp" 
     tools:layout_editor_absoluteX="8dp"/> 


</LinearLayout> 

は私MainActivity.javaは

です
package com.example.zhongjiefan.mapsapp; 

import android.app.Dialog; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.widget.Toast; 

import com.google.android.gms.common.ConnectionResult; 
import com.google.android.gms.common.GoogleApiAvailability; 
import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.MapFragment; 
import com.google.android.gms.maps.OnMapReadyCallback; 

public class MainActivity extends AppCompatActivity implements OnMapReadyCallback { 

GoogleMap mGoogleMap; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    if(googleServicesAvailable()) { 

     Toast.makeText(this, "Perfect!", Toast.LENGTH_LONG).show(); 
     setContentView(R.layout.activity_main); 
     initMap(); 

    } else { 

     // No google maps layout 
    } 
} 

private void initMap() { 
    MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.mapFragment); 
    mapFragment.getMapAsync(this); 
} 

public boolean googleServicesAvailable() { 
    GoogleApiAvailability api = GoogleApiAvailability.getInstance(); 
    int isAvailable = api.isGooglePlayServicesAvailable(this); 

    if(isAvailable == ConnectionResult.SUCCESS) { 

     return true; 
    } 
    else if(api.isUserResolvableError(isAvailable)) { 
     Dialog dialog = api.getErrorDialog(this, isAvailable, 0); 
     dialog.show(); 

    }else { 
     Toast.makeText(this, "Can't connection to play services", Toast.LENGTH_LONG).show(); 
    } 
    return false; 
} 

@Override 
public void onMapReady(GoogleMap googleMap) { 
    mGoogleMap = googleMap; 
} 
} 

答えて

0

はまだ根本的な原因を知りません。しかし、かつて私はコンピュータを交換して実行しました。それはうまく動作します。多分それはグラフィックカードのドライバまたは他のものによって引き起こされる。

関連する問題