작성
·
529
·
수정됨
0
설날을 맞이하신 강사님 새해에도
늘 건강하시고 부자되세요 ^^
프로젝트폴더에서 New >> Fragment >> Google Map Fragment 를 선택하고 Fragment Name 을 MapsFragment 로 해서 Finish 버튼을 누르면
프로젝트폴더내에 MapsFragment.kt 파일과
res/layout 폴더내에 fragment_maps.xml 파일은 생성이 되나
res/values 폴더내에 google_maps_api.xml 파일은 생성되지 않습니다
그리고 관련파일들을 실행하여도 오류는 없으나
구글맵이 나타나지 않고 빈화면만 뜹니다
git 에 파일들을 올려두었습니다
https://github.com/dongguntechnology/GoogleMap
답변 7
0
0
일러주신대로 AndroidManifest.xml 파일을 수정하여도 여전히 화면에 맵이 뜨지를 않고 빈화면만 뜨는군요 ...
제실수 앞전에 올려드린 git 주소는 private 여서 접속이 않된것 같습니다 죄송합니다
아래의 새로운 public 주소로 파일을 올려두겠습니다
https://github.com/dongguntechnology/googlemap2
공유해 주신 코드에 제 API 키를 넣어서 바로 실행했을 때 지도가 잘 표시됩니다.
키 설정에 문제가 있을 가능성이 있습니다.
GCP 콘솔에서 키 제한사항을 없음으로 설정하고 해 보시겠어요?
만약 잘 된다면 제한사항을 Android 앱으로 했을 때의 설정 중에 패키지 이름이나 Sha1 지문이 잘못 입력 된 것이 아닐까 의심됩니다.
0
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIz$%^&**(-0" />
위와 같이 해도 여전히 빈화면만 뜨네요 ...
https://github.com/dongguntechnology/GoogleMap
0
제컴 안드로이드스튜디오내 API key 가 저장된
res/values/strings.xml 파일내용입니다
<resources>
<string name="app_name">GoogleMap</string>
<string name="goodle_map_api_key">AI%^&&%$#$&*-0</string>
</resources>
0
제컴의 AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.GoogleMap"
tools:targetApi="31">
<!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow the directions here:
https://developers.google.com/maps/documentation/android-sdk/get-api-key
Once you have your API key (it starts with "AIza"), define a new property in your
project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the
"YOUR_API_KEY" string in this file with "${MAPS_API_KEY}".
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/goodle_map_api_key" />
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.GoogleMap">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="여기에 넣으세요" />
<activity
이 부분에 API_KEY 값을 넣으시면 됩니다.
0
공유해 주신 github 링크는 보이지 않아서 일단 제가 새 프로젝트로 MapsFragment 를 추가해 보았습니다.
말씀하신대로 지금은 google_maps_api.xml 은 생성되지 않네요. 대신 AndroidManifest.xml에 API 를 넣으시면 될 것 같습니다.
코드는 전혀 문제가 없기 때문에 일단 놔 두시고 진도 나가시면 될 것 같습니다.
나중에 다시 API 키 발급 받아서 진행해 보시지요