2014-07-24 4 views
0

나는지도 API를 acessing의 안드로이드 응용 프로그램 cappable을 개발하고 있어요 통해 구글 서버에 액세스 할 수 없습니다,하지만 난 오류에 붙어 : 이미 키를했고, 구글에서 everithing 활성화하십시오 안드로이드 응용 프로그램

Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

API 콘솔.

이러한 내 파일입니다

매니페스트 :

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

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

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

    <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.gms.version" 
      android:value="@integer/google_play_services_version" /> 
     <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="AIzaSyBTObQnY1mxYwXw1g8txH5ApBu8ovxv730" /> 
     <activity android:name=".MostraAlunosProximos"></activity> 
     <activity 
      android:name=".mapas" 
      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> 

</manifest> 

mapas_layout :

package hflopes.mapas; 

import android.content.Context; 
import android.os.Bundle; 
import android.support.v4.app.FragmentActivity; 
import android.support.v4.app.FragmentManager; 
import android.support.v4.app.FragmentTransaction; 
import android.util.AttributeSet; 
import android.view.View; 

/** 
* Created by HFLopes on 24/07/2014. 
*/ 
public class MostraAlunosProximos extends FragmentActivity{ 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.mapa_layout); 

     FragmentManager manager = getSupportFragmentManager(); 

     FragmentTransaction transaction = manager.beginTransaction(); 
     transaction.replace(R.id.mapa, new MapaFragment()); 
     transaction.commit(); 

    } 
} 

모든 아이디어 :지도로드에 대한

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

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


</LinearLayout> 

클래스?

도움을 주셔서 감사합니다.

답변

0

해결되었습니다!

는 build.graddle에 도움

에 대한

signingConfigs { 
     debug { 
      storeFile file("debug.jks") 
     } 
    } 

감사이 누락 된

0

나는 이것을 수행하고 내 장치에서 작동해야합니다. 시도 해봐. 로드 맵

package br.com.example.mapsexample; 

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.Toast; 

import com.google.android.gms.maps.GoogleMap; 
import com.google.android.gms.maps.MapFragment; 
import com.google.android.gms.maps.model.LatLng; 

public class MainActivity extends Activity { 

    GoogleMap mGoogleMap; 

    @Override 
    protected void onCreate(final Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     this.setContentView(R.layout.activity_main); 

     try { 
      this.initializeMap(); 
     } catch (final Exception e) { 
      // TODO: handle exception 
     } 

    } 

    @Override 
    protected void onResume() { 
     super.onResume(); 
     this.initializeMap(); 
    } 

    private void initializeMap() { 
     if (this.mGoogleMap == null) { 
      this.mGoogleMap = ((MapFragment) this.getFragmentManager().findFragmentById(R.id.mapFragment)).getMap(); 

      if (this.mGoogleMap == null) { 
       Toast.makeText(this.getApplicationContext(), "Is not possible load the map", Toast.LENGTH_SHORT).show(); 
      } 

     } 

    } 
} 

레이아웃지도에 대한

매니페스트

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="br.com.example.mapsexample" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:maxSdkVersion="20" 
     android:minSdkVersion="17" 
     android:targetSdkVersion="17" /> 

    <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="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 

    <!-- 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" > 
     <activity 
      android:name="br.com.example.mapsexample.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> 

     <!-- Goolge API Key --> 
     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="your_api_key_here" /> 
     <meta-data 
      android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version" /> 
    </application> 

</manifest> 

클래스

<RelativeLayout 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" 
    tools:context=".MainActivity" > 

    <fragment 
    android:id="@+id/mapFragment" 
    android:name="com.google.android.gms.maps.MapFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

</RelativeLayout> 
0

내가 가진 같은 일을했다.

당신의 MostraAlunosProximos 클래스에서 OnCreate이 시도

,

int status = GooglePlayServicesUtil 
       .isGooglePlayServicesAvailable(getBaseContext()); 

     // Showing status 
     if (status != ConnectionResult.SUCCESS) { // Google Play Services 
                // are 
                // not available 

      int requestCode = 10; 
      Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, 
        this, requestCode); 
      dialog.show(); 

     } else { // Google Play Services are available 

      SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager() 
        .findFragmentById(R.id.mapa); 

      // Getting GoogleMap object from the fragment 
      if (fm != null) { 
       googleMap = fm.getMap(); 
      } 

// Enabling MyLocation Layer of Google Map 
      googleMap.setMyLocationEnabled(true); 
} 

그리고 XML 파일의 fragment 내부에이 라인 android:name="com.google.android.gms.maps.SupportMapFragment"을 추가합니다. 그리고 나는 거기에 구글 플레이 서비스에 대한 두 메타 데이터가 있다는 것을 볼 수 있습니다.

희망 하시겠습니까?

관련 문제