2017-09-20 14 views
0

Googleマップの操作で新しいアンドロイドプロジェクトが作成されました。Googleマップでアンドロイドスタジオの灰色のタイルが表示されます

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 

private GoogleMap mMap; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_maps); 
    // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 
      .findFragmentById(R.id.map); 
    mapFragment.getMapAsync(this); 
} 


/** 
* Manipulates the map once available. 
* This callback is triggered when the map is ready to be used. 
* This is where we can add markers or lines, add listeners or move the camera. In this case, 
* we just add a marker near Sydney, Australia. 
* If Google Play services is not installed on the device, the user will be prompted to install 
* it inside the SupportMapFragment. This method will only be triggered once the user has 
* installed Google Play services and returned to the app. 
*/ 
@Override 
public void onMapReady(GoogleMap googleMap) { 
    mMap = googleMap; 

    // Add a marker in Sydney and move the camera 
    LatLng sydney = new LatLng(-34, 151); 
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); 
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); 
} 

}

、これが私のマニフェストです:私の活動のコードがある

<?xml version="1.0" encoding="utf-8"?> 

<!-- 
    The ACCESS_COARSE/FINE_LOCATION permissions are not required to use 
    Google Maps Android API v2, but you must specify either coarse or fine 
    location permissions for the 'MyLocation' functionality. 
--> 

<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
<uses-permission android:name="xxxxxx.permission.MAPS_RECEIVE" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<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" /> 
<uses-permission android:name="android.permission.CALL_PHONE" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="com.google.android.providers.gsf.permisson.READ_GSERVICES"/> 

<uses-permission android:name="xxxxx.mapservice.permission.MAPS_RECIEVE"/> 
<uses-permission android:name="xxxxx.provides.gsf.permission.READ_GSERVICES"/> 
<permission android:name="xxxxx.mapservice.permission.MAPS_RECIEVE" 
    android:protectionLevel="signature"/> 

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

    <!-- 
     The API key for Google Maps-based APIs is defined as a string resource. 
     (See the file "res/values/google_maps_api.xml"). 
     Note that the API key is linked to the encryption key used to sign the APK. 
     You need a different API key for each encryption key, including the release key that is used to 
     sign the APK for publishing. 
     You can define the keys for the debug and release targets in src/debug/ and src/release/. 
    --> 
    <meta-data 
     android:name="com.google.android.geo.API_KEY" 
     android:value="@string/google_maps_key" /> 

    <activity 
     android:name=".MapsActivity" 
     android:label="@string/title_activity_maps"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

と私はGoogleのAPIキーを持って、制限しますそれはsh1キーで。私はGoogleドキュメントをたどったが、残念ながら私の地図は読み込まれていない。

私はdebug.keystoreを削除しなければならないことを示唆するコメントを探していますが、これは私のためには機能しません。私は何が欠けていますか?

はまた、私のマップレイアウトxmlファイルは次のとおりです。

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:map="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/map" 
android:name="com.google.android.gms.maps.SupportMapFragment" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="ir.iuwa.testmap.MapsActivity" /> 

答えて

0

アプリケーションタグのマニフェスト外にこれを追加し、私は解決策を見つけた

<uses-feature 
android:glEsVersion="0x00020000" 
android:required="true" /> 
0

チェック! 私の間違いが正しいsha1コードを生成していました。以前、私は、このキーは、次の手順を使用してアンドロイドスタジオの右側にGradleのメニューを使用した:最初のGradleをクリックしてから、アプリ、タスク、アンドロイドの下で、私はsigningReportをクリック:その後、

enter image description here

SHA1 Gradleのコンソールに登場:

enter image description here

マイfalutは、このコードはデバッグモードのためであるということでした! 以下の手順に従ってリリースキーストアのsha1リリースを取得し、この新しいsha1をGoogle開発者コンソールに入力した後、マップが完全に表示されます。 sha1リリースを取得するには、まずリリースキーストアアドレスをコピーする必要があります。 ビルド>> generateSigendApkに移動し、キーストアパスをコピーします。

enter image description here

あなたはアンドロイドのスタジオが使用するあなたのJDKのパスをコピーしてください。ファイル>> ProjectStructureに移動すると、jdkパスが表示されます。このパスをコピーし、cmdでこのフォルダに移動します。

enter image description here

し、CDヨールJDK、その後、binフォルダとは次の行をコピーします。 のkeytool -list -v -keystore "コピーしたキーストアのPATH" -alias "KEY ALIAS" 今すぐ入力して楽しむあなたリリースsha1コード:)

関連する問題