Blank Android Google Maps v2 - android

I know that this question is asked several times, but that didn't helped me.
When I run application on my phone, I get just blank screen with zoom in and zoom out controls.
So, here is my AndroidManifest.xml code:
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="16" />
<permission
android:name="com.example.testgooglemaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.example.testgooglemaps.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" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:debuggable="true"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.testgooglemaps.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDoII86zBbwgdHr8qsI0TJqtAwsVihi7N4" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
Here I check path to my debug keystore.
Here is how it looks, when I check for SHA1 fingerprint from cmd.
Here is how it looks, when I am creating new Android key on Google API Console:

If map is not loading , in most cases it's because of API key issue. It seems that you have followed the procedures. I can suggest you 2 things ,
Try using a different debug or release keystore file and generate a new API ley from Google Apps API console.
Update your JDK , that will eventually update your keytool.exe . So, if it's due to keytool issue then this may help you.
Hope it helps.

I was facing the same problem one time and the solution was to downgrade the keytool.
Indeed, by changing the version I got a completely different key.
Bu I will not be able to give you the version.
On the others topics, they said to use the Keytool from jdk1.6.
Hope this will help

See here,just change the api key with your key in manifest file and follow these steps:
and make sure that generate api key with package name which is mentioned in android manifest file and your google_play_services_lib project should be present in your project's work space only.
Manifest file:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<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" />
<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" >
<activity
android:name="com.geeklabs.map.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="replace with your API key"/>
</application>
</manifest>
MainActivity.java:
package com.geeklabs.map;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
After got this let me know.

Related

Google Maps Api is not recognizing/working if change package ID but old package ID work -Android studio

Google map API is not working when I change project package ID. its don't load map but old package ID work and load map.
I had tried these solutions also but still not working:
1-Filter with 'Google Maps' in your logcat.
2-You will see an error message, which contains the correct package name & SHA key which should be
present as it is in the API Key
3-Go to Google Cloud Console -> API -> Credentials, and cross-verify both the above, correct if
necessary.
Wait for 10-15 minutes for the API Key changes to be reflected
Here is the Layout:
<fragment
android:id="#+id/map_view"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Here is the Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.lagoontechnologies.fclimousine">
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainNagActivity"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
<activity
android:name=".activities.MapViewActivity"
android:screenOrientation="portrait" />
</application>
Finally, I made it.
Steps to fix were:
1)I've uninstalled the application from my device
2)Deleted app-debug.apk, app-debug-unaligned.apk from android/app/build/outputs/apk
3)Deleted API Key from Google Developer Console
4)Generated new API key
5)Added new Key to in AndroidManifest.xml
6)Built my app on the device

IllegalStateException: meta-data tag in the AndroidManifest doesn't have a right value

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemaptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<permission
android:name="ca.sfu.cmpt276.bfraser.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="ca.sfu.cmpt276.bfraser.permission.MAPS_RECEIVE" />
<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" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.google.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyBR9iGtWO-bIbQ7-Fpxd8HFe9cZ53RX_Vo" />
<activity
android:name=".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>
</manifest>
Trying to figure out how Google Maps integrate with Android and Eclipse, I followed the documentation and did what I was supposed to, but I keep getting the error mentioned in the title, saying that the value isn't right, it is expecting 5089000, but is getting 0, presumably from the line
android:name="com.google.gms.version"
android:value="#integer/google_play_services_version" />
Googling this error, I've found out that most people forgot this meta-data tag, but as you can see, I put it where it's supposed to be, and I've also imported the proper library and included it in the project, but I'm still getting the error.
Anything else that might be causing this?
I've got the proper API key generated, I've downloaded Google Play Services via SDK and I don't see that I've missed any steps.
I believe it should be
android:name="com.google.android.gms.version"
not
android:name="com.google.gms.version"

Authorization Failure with Google Map API key

I am building a project for android 4.3 and building to an actual device but my google map always shows up empty and i get an authorization failure.. But everything checks out..
I have a network connection..
LOG ERROR
GOOGLE API CONSOLE
SERVICES IN CONSOLE
My Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sapientnitro.inhouse.drop"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="18" />
<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.CAMERA" />
<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" />
<permission
android:name="com.sapientnitro.inhouse.drop.activities.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission
android:name="com.sapientnitro.inhouse.drop.activities.permission.MAPS_RECEIVE"
android:required="false" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".activities.DRPSplashActivity"
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=".activities.DRPMapViewActivity"
android:launchMode="standard"
android:screenOrientation="portrait" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA7tcgqzYWAcqLd0ea5qAqHYpaYKTHQv5s" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
problem solved.. i had to uninstall the app, and do a project clean, then re-install the app.. don't know why exactly but now its working
Your API key in your manifest clearly does not match the API key you posted that is showing in the API console. Paste the API key from the console into the manifest. Should fix you right up.

Changing API Key Has No Effect

In messing around, I noticed that adding a dummy API Key to a working project's AndroidManifest.xml does not affect the project. In fact, I added key "Asfasdfasdfasfa" which isn't even valid and the project continues working.
Could someone draw light on this issue? Is there caching going?
Console:
MY:SS:HA:1K:EY;com.company.myproject
MY:SS:HA:1K:EY;com.example.gmaptest
Working manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.myproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<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" >
<activity
android:name="com.company.myproject.MainScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="asdfadf22" />
</application>
</manifest>
Take a look of this: Can I have a single Google Maps API key for all my apps without registering their package names?.
To create an API key, you provide some information that include the package name of the app. That means you are trying to validate one of your apps with a key created with another package name, this could be the issue.

Displaying Map Using Google API

I want to display map using google API. I am able to generate API key using debug.keystore but it shows only grid with label google not map i have added MapView control in xml file . what am i missing?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="8" />
<permission
android:name="com.example.maptest.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.example.maptest.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" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.maptest.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="com.google.android.gms" />
<uses-library android:name="com.google.android.maps" android:required="true" />
</application>
I think you have not added a reference to the Google Play Services library to your project. See this guide Google Maps Android v2 for more further helps.
Please check whether you used Google android map in console and not Google Map. This might also be a problem. In addition to that another problem may be, you might have used map fragments. Use support Fragment in xml
android:name="com.google.android.gms.maps.SupportMapFragment"
GoogleMap gm;
gm = ((SupportMapFragment)(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();
You are most likely missing some permission(s) in your Manifest, probably MAPS_RECEIVE or READ_GSERVICES. Check this related question.
Edit: Insert your API key just before the closing tag </application>:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your_api_key"/>
Add the ACCESS_NETWORK_STATE permission:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Delete these lines:
<activity android:name="com.google.android.gms" />
<uses-library android:name="com.google.android.maps" android:required="true" />

Categories

Resources