2016-07-05 9 views
1

私は1つのアクティビティを含む非常に基本的なアプリケーションを開発し、Googleマップ(私はGoogleマップAPIを使用しました)を表示します。コンパイルはエラーなしで終了しますが、apkも問題なく生成しますが、別のデバイスでアプリケーションを実行すると、このページの下にGoogleの記号が表示される空白のページのみが表示されます。私はGoogle Map APIのヘルプが必要です

[![This the screenshot of my application][1]][1] 


package com.example.amine.bea_mapapp; 

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)); 
    } 
    } 

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">My API key is here</string> 

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.amine.bea_mapapp"> 
<permission android:name="com.androidcom.example.amine.bea_mapapp.MAPS_RECEIVE" android:protectionLevel="signature"/> 
<uses-permission android:name="com.androidcom.example.amine.bea_mapapp.MAPS_RECEIVE"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="com.androidcom.example.amine.bea_mapapp.providers.gsf.permission.READ_GSFREVICES"/> 
<uses-feature android:glEsVersion="0x00020000" 
    android:required="true"/> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 

    <meta-data 
     android:name="com.google.android.geo.API_KEY" 
     android:value="My API key is here" /> 

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

+1

ログには、生成したapkファイルのAPIキー –

+0

に関連するエラーがあります。 apkまたはapkをデバッグしました..? –

答えて

1

にGoogle APIキーに問題があることをようです。まだ問題に苦しんでいる場合、あなたはあなたのマシンから生成されたキーストアを使用して新しいGoogleマップAPIキーを生成し、その新しいMAP APIキーでAPKを構築し、

<meta-data 
     android:name="com.google.android.geo.API_KEY" 
     android:value="My API key is here" /> 

でどのようなキーを使用しています。私はそれがすべてのデバイスで動作すると確信しています。あなたは、そのデバイスにのGoogleアカウントをチェックする必要が

1

まず最初は、あなたの試験装置における二つ目のチェック作り付けのマップが正常に動作するかしないでか 記録されます。 Googleマップはデバイスの既存のマップアプリケーションとGoogleアカウントからいくつかのサービスにアクセスするためです。

+0

はい、これらのことはアンドロイドアプリケーションのマップには必須です。 – Ramkailash