Android Maps API key is correct, but the map does not appear

TL DR

We need to move

<uses-permission android:name="android.permission.INTERNET"/> 

under

</application> 

Original question

Hi, I am new to Android development. I tried the "Hello Google Maps" tutorial and I can’t view the map. I signed up for an API key. I am using Eclipe, which is installed on drive "D". The following command is used to get the MD5 fingerprint from the bin folder of my jdk installation:

c:\program files\java\jdk 1.6\bin> keytool -list -alias androiddebugkey -keystore "C:\Documents and Settings\Owner\.android\debug.keystore" -storepass android -keypass android

I got this print

21:17:B1:D8:01:BD:F2:5A:9F:C9:A3:01:96:FA:9A:5B

Used this to find the API key and got it

"0Gm7C3R3R2K1pmQGuGkS0rx582TWJEBdJwryFrA"

The following code is used in the layout.

<com.google.android.maps.MapView
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:apiKey="0Gm7C3R3R2K1pmQGuGkS0rx582TWJEBdJwryFrA"
             />

Map is not displayed. Please enlighten me about this. thanks in advance

LogCat Error Log

11-25 03:14:38.432: ERROR/AndroidRuntime(10857): ERROR: thread attach failed
11-25 03:14:42.162: ERROR/AndroidRuntime(10866): ERROR: thread attach failed
11-25 03:14:45.562: ERROR/AndroidRuntime(10877): ERROR: thread attach failed
11-25 03:14:47.402: ERROR/MapActivity(10885): Couldn't get connection factory client
11-25 03:14:50.652: ERROR/PackageInstallationReceiver(6465): Remove /data/local/tmp/com.testGoogleMap.apk Fail!
11-25 03:14:58.952: ERROR/wpa_supplicant(1683): wpa_supplicant_ctrl_iface_ap_scan: 2
11-25 03:14:58.952: ERROR/wpa_supplicant(1683): Scan request
11-25 03:14:59.802: ERROR/wpa_supplicant(1683): wpa_supplicant_ctrl_iface_ap_scan: 1

My manifest file

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


<application android:icon="@drawable/icon" android:label="@string/app_name"  android:debuggable="true">
    <uses-permission android:name="android.permission.ACCESS_INTERNET"/>
    <uses-library android:name="com.google.android.maps"/>
    <activity android:name=".HelloGoogleMaps"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>

</application>
<uses-sdk android:minSdkVersion="7" />


</manifest> 

Modified manifest

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

<application android:icon="@drawable/icon" android:label="@string/app_name"  android:debuggable="true">

    <uses-library android:name="com.google.android.maps"/>
    <activity android:name=".HelloGoogleMaps"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

    </activity>

</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-sdk android:minSdkVersion="7" />

+3
source share
2

, , AndroidManifest.xml:

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

    <uses-permission android:name="android.permission.INTERNET" />

    <uses-sdk android:minSdkVersion="3" /> 

    <application android:icon="@drawable/icon"
                 android:label="@string/app_name" 
                 android:debuggable="true">   

      <activity android:name="<package>.Activity"
                android:label="@string/app_name"
                android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      </activity>

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

    </application>

  </manifest>

, :

  • INTERNET
  • uses-library
+3

, Google API, Google Maps .

: . ACCESS_INTERNET, INTERNET. android.permission.INTERNET.

+1

Source: https://habr.com/ru/post/1776783/


All Articles