I am displaying MAP using google map Api V2 i successfully displayed it in device when am running through my PC but now i am signing my application via export signed apk and made as .keystore and .apk and it made a certificate and now i am using that apk file and runnning the application but the map does not displayed just showing white screen, even i made a release key using
http://developer.android.com/tools/publishing/app-signing.html and i succesfully performed all the steps given in the link but then too the map is not displaying, please help.
Thanks.
You must need to create new map api key with your newely create keystore and put it on Google Map Api Console page. Use below command:
PATH OF YOUR KEYTOOL FILE/keytool -list -v -keystore YOURKEYSTORENAME
You will get SHA-1, save it. Go to Google api console page, create new Android key using this SHA-1 and put newely created key into your app. It will work for sure.
you need to sign your maps with release key ;) you signed your map with debug.keystore
how to get a Google Maps API v2 release key
Google Maps v2 Getting started
My public class VentanaMapa extends FragmentActivity
when private GoogleMap mMap;
status = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getBaseContext());
Intent intentErrorMapa = null;
switch (status) {
case ConnectionResult.SUCCESS:
SupportMapFragment SupportMap = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mMap = SupportMap.getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.getUiSettings().setZoomControlsEnabled(true);
mMap.getUiSettings().setCompassEnabled(true);
new ObtenerEnvio().execute(_empAlbaran, _codAlbaran.toString(),
_lineaAlbaran.toString());
mMap.setMyLocationEnabled(true);
break;
case ConnectionResult.SERVICE_MISSING:
Toast.makeText(VentanaMapa.this, R.string.ErrorMapaServiceMissing,
Toast.LENGTH_LONG).show();
break;
case ConnectionResult.SIGN_IN_REQUIRED:
Toast.makeText(VentanaMapa.this, R.string.ErrorMapaSignRequired,
Toast.LENGTH_LONG).show();
break;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
Toast.makeText(VentanaMapa.this, R.string.ErrorMapaServiceUpdate,
Toast.LENGTH_LONG).show();
break;
case 999:
Toast.makeText(VentanaMapa.this, R.string.ErrorCargarMapa,
Toast.LENGTH_LONG).show();
break;
}
My Map.xml:
`<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_above="#+id/ImageButtonAnteriorMapa"
android:layout_alignParentTop="true" />
</RelativeLayout>
1) create a release key, for sign your app. SHA1 that you have you need to go to Google Api console. Create new Android key like SHA1_number;your.package
2) with this key you need to add in your manifest like:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="your_key_for_release" />
your put that code before </application>
that's it. check logcat to see exactly which message you recive from Google Maps
I Faced the Same Problem,Finally Got a Solution, Kindly check your Developer Account,It have permission for Api key generation follow this steps to show your map in google play signed apk
1. Create the Api using Debugging SHA1.
(eg)F0:0F:F0:0F:F0:0F:F0:0F:F0:0F:F0:0F:F0:0F:F0:0F:F0:0F:F0:0F;com.blabla.app
2.Create the Api using Relased SHA1 from appname.keystore.
(eg)F2:83:F2:83:F2:83:F2:83:F2:83:F2:83:F2:83:F2:83:F2:83:F2:83;com.blabla.app
you have an option to create on this api in single textfield in developerId api console page.
This kind of option are available only in developer account.Try it.Thank you.
Please refer the following Image if u have any doubt.
In the Google API console have you add your signed sha1 Key and change it in your Manifest.xml ?
Because, signed and debug keystore and completely different, with Eclipse, when you Export your project as an Android Application, you choose a keystore and before clicking finish, there is a sha1 key at the bottom of the window. You've to add this specific key in the API Console.
try this
1.first create the .APK file in eclipse in the console as shown this see this image
2.copy the SHA1 key and then create the API Key
using this .Google APIs Console
3 and past the API key into ur project and then create the APK file
To find out the Android SHA1 fingerprint for release keystore, follow these steps:
Open terminal
Change the directory to the JDK bin directory, mine was jdk1.7.0_05 (could be different for you).
cd C:\Program Files\Java\jdk1.7.0_05\bin
Next we have to run the keytool.exe. Use the following line to get the SHA1 fingerprint.
keytool -list -v -keystore {keystore_name} -alias {alias_name}
Example:
keytool -list -v -keystore C:\Users\MG\Desktop\test.jks -alias test
It will prompt for a password.
Enter the password, you will get the SHA1 and MD5 fingerprint.
Related
I am able to view google maps on Emulators and on my device when USB debugging is enabled. But when I try to generate a debug / release apk and install the apk on my device, I am unable to view the maps.
I have done the following:
a) Generated API Key in https://console.developers.google.com/ and have copied it into google_maps_api.xml of my project.
b) I have generated the necessary SHA key using the following command.
keytool.exe -list -v -alias <myalias> -keystore <my path> -storepass <passwd> -keypass <passwd>
What I am not able to understand is, how do I use the generated SHA?
As per Release APK file not showing google maps I am supposed to add the SHA key into my API key on https://console.developers.google.com/. But, I see no such option to add it.
By installing the apk and then debugging the installed code on an emulator, I see the following exception:
API Key must not be empty.
My google_maps_api.xml is as follows:
<resources>
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">Have added my api key here</string>
Have added my api key here --> This is where I have added the API ket that I have generated.
Have added this into my manifest file:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
Can someone help me out in understanding what is it that I am supposed to do?
I was finally able to fix this issue and these were the steps I followed [on a windows machine, should be much more easier on a mac]:
a) cd into C:\Program Files\Java<jdk version>\bin [or wherever your jdk is installed].
b) Run: keytool -list -v -alias -keystore "{keystore ie., .jks file loc}" -storepass {your store password} -keypass {your keypass}
c) By running the keytool cmd, your SHA1 file would then be generated.
d) Login to https://console.developers.google.com/
e) In your project there will be a google_maps_api.xml file. In this file there is a commented url, something like this: https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r={your SHA1 key}%3B{your project package}.
f) In the link above, replace the default SHA1 key with the newely generated key and open the link on a browser from where you already have logged into google develover console.
h) Follow the steps as prompted on the browser and with this you should be able to generate an API key.
i) Paste the generated API key here:
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">API key</string>
This is available on your google_maps_api.xml file.
j) Now go to {your project location}\app\src\release\res\values and open the google_maps_api file. Here again, replace your API key in the location mentioned in point (i) ie., the code snippet.
k) Finally go to Android Studio > Your Project > Build > Generate Signed Bundle / APK > {input keystore path and passwords as per point (b)} > select debug/release version > Finish
The debug or release apk generated will now allow you to access google maps.
Im implementing an android app that enables users to stream to a youtube channel straight from the app. I have created an API key and a OAuth 2.0 client ID
But I get a the following exeption: com.google.android.gms.auth.GoogleAuthException: UNREGISTERED_ON_API_CONSOLE either when I try to ceate an event or when i try to fetch the one a created manually on the youtube channel.
I use the following code for create a youtube object
String accountName = mContext.getString(R.string.google_account_name);
String apiKey = mContext.getString(R.string.google_api_key);
String clientID = mContext.getString(R.string.google_api_client_id);
String clientName = mContext.getString(R.string.google_api_client_name);
GoogleAccountCredential credential =
GoogleAccountCredential.usingOAuth2(mContext,
Arrays.asList(YouTubeScopes.YOUTUBE));
credential.setSelectedAccountName(accountName);
// String SCOPE = "audience:server:client_id:" + clientID + ":api_scope:" + YouTubeScopes.YOUTUBE;
// GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(mContext, SCOPE);
// credential.setSelectedAccountName(accountName);
youtube = new YouTube.Builder(transport, jsonFactory, credential)
.setApplicationName(clientName)
.setYouTubeRequestInitializer(new YouTubeRequestInitializer(apiKey))
/*.setGoogleClientRequestInitializer(new YouTubeRequestInitializer(apiKey))*/
.build();
Then to create an event:
LiveBroadcastSnippet broadcastSnippet = new LiveBroadcastSnippet();
broadcastSnippet.setTitle(name);
broadcastSnippet.setScheduledStartTime(new DateTime(futureDate));
LiveBroadcastContentDetails contentDetails = new LiveBroadcastContentDetails();
MonitorStreamInfo monitorStream = new MonitorStreamInfo();
monitorStream.setEnableMonitorStream(false);
contentDetails.setMonitorStream(monitorStream);
// Create LiveBroadcastStatus with privacy status.
LiveBroadcastStatus status = new LiveBroadcastStatus();
status.setPrivacyStatus("unlisted");
LiveBroadcast broadcast = new LiveBroadcast();
broadcast.setKind("youtube#liveBroadcast");
broadcast.setSnippet(broadcastSnippet);
broadcast.setStatus(status);
broadcast.setContentDetails(contentDetails);
// Create the insert request
YouTube.LiveBroadcasts.Insert liveBroadcastInsert = youtube
.liveBroadcasts().insert("snippet,status,contentDetails",
broadcast);
// Request is executed and inserted broadcast is returned
LiveBroadcast returnedBroadcast = liveBroadcastInsert.execute(); //<= This line generates the exception
I obviously did something wrong, but I can't figure out what. Any help is appreciated. Thanks in advance
The issue is that, when you debug, you're using a keystore created in ~/.android/debug.keystore, and not whatever signing key you think you're using.
When you generate a key, such as to release a signed APK, you think that this SHA1 is the one required by the Google API interface. It isn't.
If you replace the one in the ~/.android folder with your signing key, it's corrupt because it's missing the androiddebugkey. FYI, the default password for the auto-generated key is "android".
For directions as to where your keystore is located, see https://developer.android.com/studio/publish/app-signing.html under "Expiry of the debug certificate".
What you have to do:
1) Delete your debug.keystore and restart your IDE. This should generate a new debug.keystore with key alias "androiddebugkey".
2) If your IDE does not generate the new keystore, re-run your android application. It should generate it this time in ~/.android/
3) Navigate to /path/to/jre/bin and add this path to your system environment variables. This will allow you to access keytool.
4) Navigate to the directory of your debug keystore and run this command: keytool -list -keystore debug.keystore -alias androiddebugkey
5) Your console will prompt you to enter the keystore password (it is "android").
6) Get the SHA1 key from the keystore and put THAT KEY into your API interface, and you'll find it works.
In my case the UNREGISTERED_ON_API_CONSOLE error was caused by misspell in package name in AndroidManifest. Simple but lost many hours struggling with keys and SHAs.
Using the answers before this, I used it as a reference to understand and fix mine and made a much easier step-by step procedure of how I fixed mine.
In Windows command prompt.
Navigate to you java bin directory.
C:\Program Files\Java\jdk1.8.0_111\bin>
and type the ff. command
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
then run the ff. code
keytool -list -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey
when ask for password, type "android" (without double quotes)
the resulting SHA1 key from the above code. Copy it, and paste it on your google cloud console here
On the google cloud console webpage do this
on the tab on the left, find and click "APIs & Services"
then on the new page, on the left tab again, find and click "Credentials"
now copy paste the key you copied from windows command prompt on the textbox below the "Signing-certificate fingerprint"
make sure that the application id on your app and google cloud console matches each other.
I've this problem, and after a lot of search, in build.gadle my applicationId was diferent from the package name that i've putted on Google Console
defaultConfig {
applicationId "br.com.glicado.glicado" <-- WAS WRONG, IN MY CASE THE RIGHT IS "br.com.glicado"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
I am using the map functionality in my app.Whenever I run map in my app I got error i.e.
04-19 11:03:50.274: E/Google Maps Android API(23366): Failed to load map. Could not contact Google servers.
I have checked manifest file and code all is correct.And Google play service is also working in my android device. I am running sample code of map same error I have got.But I am not understanding what is exact problem.Please suggest me how to fix that problem.
`
Have you adquire your map-key in Google Api Console using the package name of your project and your SH1 of the Keytore?
If not, go to console and do it ;)
You have to put this key in your Manifest, and the permissions required.
Normally this error happens when:
No valid map-key.
The key is not for your keystore.
You forgot some permision.
===============Mini tutorial=====================
Download and install Google Play Services from SDKManager
Go to Google Api Console
On your left, Create new Project (Give the name you want)
Know in the "services" option is allowed, so go inside the option.
Turn On Google Maps Android API v2
Know in click on "Generate new Android Key" in the page showed
You will need your SHA1 from the Keystore and the name of the project package
Ex: 48:+4: ... :46;com.xxxx.xxx.xxx
To know your sha1 you have to open a CMD and do:
C:\>cd C:\Users\YOURUSER\.android\
C:\Users\YOURUSER\.android>"C:\Program Files\Java\jdkXXXX\bin\keytool.exe" -list -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android
XXX Means the version you have
Now you got your api key go to your Manifest have to put:
...
...
Select the project, right click, go to "File/Import/Android/Existing Android Code into Workspace". In the root directory go to "<-sdk-android folder> /extras/google/google_play_services/libproject/google-play-services_lib"
and select the project that appears. Click Finish.
Right click on project go to "Properties/Android"; click on "Add.." button, and choose google play services and click on OK
Add android-support-v4.jar to your project if isn't yet.
THe layout of the map is:
And the activity that contains the map has to extend FragmentActivity (Something like this)
public class MainActivity extends android.support.v4.app.FragmentActivity
{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
...
}
AAAAND thats all!
Have you generated an api key for your app, using your keystore and package name?
I am following this link http://eagle.phys.utk.edu/guidry/android/apiKey.html to generate MD5 fingerprint of the certificate.
I have seen following threads too :
Google maps error when trying to get my API Key for android
How to find the MD5 fingerprint of my Android App
I am using Windows xp OS .The debug.keystore is located at C:\Documents and Settings\Admin.android\debug.keystore.
but on cmd prompt it gives response network path not found.
Please guide me how can i generate MD5 digest.
And also I would like to know what is the difference in debug key
and release
key ?? Are these two different keys ?? If yes then
How
can i generate them ??
Is there any way by adopting that we can use same debug and release
keys on different machines.
Locate debug.keystore on your system. It is usually in the USER_HOME\Local Settings\Application Data\.android folder on windows.
Use the keytool utility to generate certificate fingerprint (MD5). keytool utility that comes with the default JDK installation.
C:>keytool -list -alias androiddebugkey -keystore .android\debug.keystore -storepass android -keypass android
You can get a temporary Maps API Key based on your debug certificate, but before you publish your application, you must register for a new Key based on your release certificate and update references in your MapViews accordingly
You may also have to obtain other release keys if your application accesses a service or uses a third-party library that requires you to use a key that is based on your private key. For example, if your application uses the MapView class, which is part of the Google Maps external library, you will need to register your application with the Google Maps service and obtain a Maps API key. For information about getting a Maps API key, see Obtaining a Maps API key.
refer this:
get your debug signature as described below
$ keytool -list -keystore ~/.android/debug.keystore
...
Certificate fingerprint (MD5): 94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98
or better use the one you get from sigs[i].hashCode()
then this util func may also help
static final int DEBUG_SIGNATURE_HASH = 695334320;// value shpuld be the one you get above
public static boolean isDebugBuild(Context context) {
boolean _isDebugBuild = false;
try {
Signature [] sigs = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).signatures;
Log.d(TAG, "DEBUG_SIGNATURE_HASH->"+DEBUG_SIGNATURE_HASH);
for (int i = 0; i < sigs.length; i++) {
Log.d(TAG, i+"->"+sigs[i].hashCode());
if ( sigs[i].hashCode() == DEBUG_SIGNATURE_HASH ) {
Log.d(TAG, "This is a debug build!");
_isDebugBuild = true;
break;
}
}
} catch (NameNotFoundException e) {
e.printStackTrace();
}
return _isDebugBuild;
}
I have been trying to obtain a public map api key for my Android app. However the public key that I receive from Google does not work.
I have been using the following steps:
Obtaining Release Public Map API Key
1.Obtain Private Key:
Use Export of Eclipse to sign release application and create new keystore
2.Obtain MD5 certificate:
using alias and keystore set up
use keytool in Java directory: keytool -list -alias poly_alias -keystore
copy MD5 certificate
3.Obtain API Map Key:
Visit http://code.google.com/android/maps-api-signup.html and enter MD5 certificate
copy key
4.Use New Map API Key:
insert new map key for string in strings.xml for string mapApiKey
Does anyone have any suggestions on what I am doing wrong?
You were sketchy on the last step, so you may want to look at the final two steps on this page:
http://code.google.com/android/add-ons/google-apis/mapkey.html#finalsteps.
If it still doesn't work, you may want to explain what is happening, and change the values, but you may want to show an example of one of your layout files and the android manifest, to see if you may have made a typo or something.
You are following instructions for using the release signing key. Make sure you are building your APK in release mode. Normally, you build in debug mode and would use a Maps API key based on the debug signing key.