Google Maps API v2 gray screen

I am trying to create an application that connects to Google maps. But when the screen loads, when the card should just be gray. How to fix it?

Important message from my logcat.

06-11 03:32:55.196: E/Google Maps Android API(11671): Ensure that the following correspond to what is in the API Console: Package Name: my pacakage, API Key: my key, Certificate Fingerprint: my fingerprint 

Activities

 import android.os.Bundle; import android.view.Menu; import android.support.v4.app.FragmentActivity; public class mapPage extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_page); } @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; } } 

manifest

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my package" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <permission android:name="my package.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> <uses-permission android:name="my package.permission.MAPS_RECEIVE"/> <!-- Copied from Google Maps Library/AndroidManifest.xml. --> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <!-- External storage for caching. --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <!-- My Location --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <!-- Maps API needs OpenGL ES 2.0. --> <uses-feature android:glEsVersion="0x00020000" android:required="true"/> <!-- End of copy. --> <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.maps.v2.API_KEY" android:value="my key"/> <activity android:name="my package.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> <activity android:name=".main"> </activity> <activity android:name=".mapPage"> </activity> <activity android:name=".ThirdPartyWeb" android:theme="@android:style/Theme.Dialog"> </activity> </application> </manifest> 

Layout

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_alignParentTop="true" android:layout_centerInParent="true" android:layout_height="250dp" android:layout_width="fill_parent" class="com.google.android.gms.maps.SupportMapFragment"/> <ImageView android:layout_alignParentTop="true" android:layout_centerInParent="true" android:layout_height="50dp" android:layout_width="fill_parent" android:background="@color/darkGrey"/> <Button android:layout_alignParentTop="true" android:layout_marginTop="10dp" android:layout_alignParentLeft="true" android:id="@+id/menuButton" android:background="@drawable/icon_menu" android:layout_height="30dp" android:layout_width="30dp"/> <Button android:layout_alignParentTop="true" android:layout_marginTop="10dp" android:layout_toRightOf="@+id/menuButton" android:layout_marginLeft="20dp" android:id="@+id/" android:background="@drawable/icon_off" android:layout_height="35dp" android:layout_width="55dp"/> <EditText android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_marginTop="10dp" android:layout_toRightOf="@+id/" android:layout_marginLeft="20dp" android:layout_toEndOf="@+id/" android:id="@+id/seachBox" android:hint="@string/search" android:layout_height="35dp" android:layout_alignParentEnd="true" android:background="@color/white"/> <Button android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_marginTop="10dp" android:id="@+id/searchButton" android:background="@drawable/graphic_search" android:layout_height="35dp" android:layout_width="20dp"/> <ImageView android:layout_above="@+id/newsFeed" android:layout_centerInParent="true" android:layout_height="35dp" android:layout_width="fill_parent" android:background="@color/darkGrey"/> <TextView android:layout_alignParentLeft="true" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_above="@+id/newsFeed" android:layout_marginBottom="11dp" android:textColor="@color/white" android:text="@string/news_feed" android:textAppearance="?android:attr/textAppearanceSmall"/> <ListView android:layout_alignParentBottom="true" android:id="@+id/newsFeed" android:layout_width="fill_parent" android:layout_height="wrap_content">" </ListView> </RelativeLayout> 
+6
source share
6 answers

Solve the problem well. There are two google api v2 maps on google api console. I had one only for google maps api v2, if you look just above it, says Google Maps v2 android. I turned it on and the card is working.

+11
source

As you can see from this error, it seems that your configurations in the Google API console are incorrect. Take a look at this blog post I wrote and make sure that you take all the steps correctly:

Maps API V2 API Key

+4
source

@rajwant rai: maybe your code is for API v1, because I use API v2, and such code is not needed.

@author: You test it on a phone or emulator. Some google services must be installed on the phone for the card to work. How to better prepare a working draft: https://developers.google.com/maps/documentation/android/start

+1
source

There are two modes. release mode and debug mode, if you want to use in release mode, then you want the custom font to be printed. debug mode - normal mode.

https://developers.google.com/maps/documentation/android/start#obtaining_an_api_key

See Displaying the fingerprint of a fingerprint and debugging fingerprint printing when highlighted.

+1
source

try adding the following manifest file (after the metadata tag)

  <uses-library android:name="com.google.android.maps" android:required="true" /> 
0
source

I had the same problem, but for me the application stopped working. I found out that this is the problem with debug.keystore that Eclipse generates. This can happen if:

  • The source code is updated from the repo, but debug.keystore obtained from the local directory USER_DIR.android\debug.keystore
  • You have a disk failure and you have not restored the old debug.keystore
  • you deleted USER_DIR.android\debug.keystore somehow

To confirm this problem, get SHA1 from your USER_DIR.android\debug.keystore and compare with that from the Android Console . They must be the same. If you are not trying to generate new Android applications for Android, follow this guide .

Once you receive it, update the AndroidManifest.xml file

 <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="NEW_API_KEY"/> 

and clear the entire ./bin directory. Do it manually, do not trust Project -> Clean ... in Eclipse. Remove the application from the device before installing it.

To avoid this problem in the future, add a debug repository for the repo. Keep the release secret.

0
source

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


All Articles