Android map is NOT shown. Grids only

PROBLEM SOLVED Solution Brief: Make sure you are not api v1 classes. Right now, when I was working, the emulator was useless for testing the application. Therefore, check it on the device itself. Finally, if the application works correctly but does not display a map, then you have a key problem. I noticed here that catlog does not say that the key is incorrect, the application starts, but the map does not appear.

I have been trying for 2 days to make one simple Android application with a Google map, which simply displays the map on Activity, but failed. I tried every tutorial up to the second page of Google. Nothing works. What works a little is just the application that I follow in the book. But it shows the grid and the MAP. Usually people give the answer that the key is wrong, but it is not. My key is right, I worked neatly in key generation. I am using Google Maps Android API v2.

Here is my activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <com.google.android.maps.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="0AeGR0UwGH4pYmhcwaA9JF5mMEtrmwFe8RobTHA" android:clickable="true" android:enabled="true" /> </LinearLayout> 

Here is my MainActivity.java

 package com.example.lbs; import android.os.Bundle; import android.view.Menu; import com.google.android.maps.MapActivity; public class MainActivity extends MapActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } } 

Here is my AndroidManifest.xml

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.lbs" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <uses-permission android:name="android.permission.INTERNET" /> <permission android:name="com.example.lbs.permission.MAPS_RECEIVE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.lbs.permission.MAPS_RECEIVE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="com.google.android.maps" /> <activity android:name="com.example.lbs.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> </application> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyB1RpoULFVTRkXREZX0ZAwxcz4_75Y0HYc" /> </manifest> 

enter image description here

In catlog, when the application is running, I get this

 IOException processing: 26 java.io.IOException: Server returned: 3 at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115) 

Update 1: After all, as I read in some places, the code can only be for the API v1 key. So I completely completed the tutorial from the beginning of https://blog-emildesign.rhcloud.com/?p=435 and I ended up with this

enter image description here

UPDATE 2: Now I tried to get it working on a real Android device. This is android 2.3. So do a little more work. I am finishing my activity

enter image description here

and what I see in my CatLog,

enter image description here

So, the map is not yet displayed ... Please help ...

Update 3: The problem was with the API key. I could not see anything in logcat about the wrong key. The application starts, but does not display a map. Therefore, I restored the key. AND HERE WE GO enter image description here

+4
source share
3 answers

Your problem is that you are creating a key for the Google Maps API V2, but you are trying to use the Google Maps MapView API object:

  <com.google.android.maps.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:apiKey="0AeGR0UwGH4pYmhcwaA9JF5mMEtrmwFe8RobTHA" android:clickable="true" android:enabled="true" /> 

Instead, you should use MapFramgent or SupportMapFragment , depending on what level of API you are targeting, you can get a complete explanation of how to integrate the Google Maps V2 API into your application in this guide, which I wrote on this subject:

Google Maps API V2

UPDATE:

The second screenshot is what you expect to get on the emulator. Google Play Services not installed on the emulator and the reason why you see what you see. try testing this app on a device with Google Play Services and it should work.

+1
source

Check it! I also had a similar problem. This worked for me !. 1) Go to the Google API Console if an API key has been created. 2) Click on segments (displayed in the options on the left). 3) Move your cursor and find the Google Maps Android API v2. 4) Turn it on (it was initially disabled, only gray tiles appeared).

+1
source

In the Google APIs Console, under your key for Android applications, make sure that you add both the fingerprints - debug and release.

0
source

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


All Articles