2016-12-03 8 views
0

나는이 문제를 해결하기 위해 노력하고 시도했습니다. 나는 모든 곳에서 수색했으며 아직 해결책을 찾지 못했습니다. 이 주제에 대한 많은 포럼이 있다는 것을 알고 있지만 해결 방법을 찾지 못했습니다.MapActivity를 사용하는 Android 애플리케이션에서 Google API를 사용하는 중에 오류가 발생했습니다.

내가 겪고있는 문제는 내 안드로이드 응용 프로그램을 실행할 때 에뮬레이터에서지도 영역이 회색 타일로만 표시된다는 것입니다. 나는 문제가 구글 API 키일 가능성이 가장 높다는 것을 온라인에서 읽었지만 그것을 생성하는 방법을 여러 번 시도했다. (SHA1을 얻기 위해 안드로이드 스튜디오 터미널을 사용했고, 안드로이드 스튜디오가 구글 링크를 생성하여 자동으로 만들 수있게했다. 열쇠).

나는 누군가가 나를 도울 수 있기를 바라고있다. 나는 꽤 절망적이다.

내 활동 등급은 다음과 같습니다 package com.bignerdranch.android.taskmanager;

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

    <TextView 
     android:id="@+id/location_title" 
     .../> 

    <EditText 
     android:id="@+id/task_address" 
     .../> 

    <Button 
     android:id="@+id/map_location_button" 
     .../> 

    <com.google.android.maps.MapView 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/map_location_button" 
     android:layout_above="@+id/use_this_location_button" 
     android:clickable="true" 
     android:apiKey="AIza.................................." /> 

    <Button 
     android:id="@id/use_this_location_button" 
     .../> 

</RelativeLayout> 

그런 다음이 매니페스트 파일 :

import android.os.Bundle; 

import com.google.android.maps.MapActivity; 

public class AddLocationMapActivity extends MapActivity { 

    public static final String ADDRESS_RESULT = "address"; 

    @Override 
    protected void onCreate(Bundle bundle) { 
     super.onCreate(bundle); 
     setContentView(R.layout.add_location); 
    } 

    @Override 
    protected boolean isRouteDisplayed() { 
     return false; 
    } 

    @Override 
    protected boolean isLocationDisplayed() { 
     return true; 
    } 

} 

레이아웃입니다 그리고

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

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

    <application 
     android:name=".TaskManagerApplication" 
     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.maps.v2.API_KEY" 
      android:value="AIza..........................." /> 
     <activity android:name=".ViewTasksActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 

       <category android:name="android.intent.category.LAUNCHER"/> 
      </intent-filter> 
     </activity> 
     <activity android:name=".AddTaskActivity" 
        android:text="@string/add_task"/> 
     <activity android:name=".AddLocationMapActivity" 
        android:text="@string/add_location_to_task"/> 

     <uses-library android:name="com.google.android.maps" /> 
    </application> 

</manifest> 

가 build.gradle 파일 :

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 'Google Inc.:Google APIs:24' 
    buildToolsVersion "24.0.2" 

    defaultConfig { 
     applicationId "com.bignerdranch.android.taskmanager" 
     minSdkVersion 16 
     targetSdkVersion 24 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:24.2.1' 
    compile 'com.google.android.gms:play-services-maps:10.0.1' 
    compile 'com.google.android.gms:play-services-location:10.0.1' 
} 

그리고 마지막으로 , Monito가 생성 한 것입니다. R :

12-02 22:37:10.351 22387-22537/com.bignerdranch.android.taskmanager W/System.err: IOException processing: 26 
12-02 22:37:10.351 22387-22537/com.bignerdranch.android.taskmanager W/System.err: java.io.IOException: Server returned: 3 
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err:  at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115) 
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err:  at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473) 
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err:  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117) 
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err:  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994) 
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err:  at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702) 
12-02 22:37:10.352 22387-22537/com.bignerdranch.android.taskmanager W/System.err:  at java.lang.Thread.run(Thread.java:818) 

나는 ME이 문제를 알아낼 수 있습니다 사람에게 영원히 감사하겠습니다! Grey tiles instead of map

답변

0

com.google.android.maps.MapView를 사용중인지도는 Google지도 API의 v1입니다. 불행히도 공식적으로 사용되지 않습니다. 당신은 여기에서 버전 2

입니다 Google Maps API의 새 버전을 사용해야합니다

이 내 문제입니다 Google Map V2

+0

에 대한 튜토리얼입니다! 고맙습니다! 하지만이 특정 코드를 V2로 "변환"하는 방법에 대한 지침이 있습니까? – AlwaysWin

+0

V2 버전이 너무 다르기 때문에 저의 답변에 튜토리얼을 추가했습니다. –