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.
Related
Am trying to find a way to get SHA256 of a mobile app,i have search around but i didn't understand some of the things i came across. i tried
MessageDigest md = MessageDigest.getInstance("SHA");
try {
md.update(toChapter1);
MessageDigest tc1 = md.clone();
byte[] toChapter1Digest = tc1.digest();
md.update(toChapter2);
...etc.
} catch (CloneNotSupportedException cnse) {
throw new DigestException("couldn't make digest of partial content");
}
and also if you can explain the concept i will be glad
To access APIs in Android from Google API console you need to generate an API Key. This same API key can be used for accessing multiple APIs under the same project. To generate an API key you require, SHA1 fingerprint of your keystore. Keystore is basically a place where the private keys for your app are kept. In simple words its a certificate generated by a user or a program, used for signing an Android app.
In Android, there are two types of keystores. A debug keystore and a release keystore. Debug keystore is generated automatically when the Android SDK is installed or run for the first time. Release keystore has to be generated manually by the user for each application before release. As it requires private information such as name, password etc. To obtain an Android SHA1 fingerprint from your desired keystore.
i found a Hashing Library at android arsenal and its very easy,simple and just one line of code. can hash MD5, SHA-1, SHA-256, SHA-384, or SHA-512.
1.first add this to your gradle and sync
implementation 'com.github.1AboveAll:Hasher:1.2'
Start hashing...
Hasher.Companion.hash("Hello",HashType.SHA_1);
I am trying desperately to export my signed APK after building my Unity project for Android as a "Google development build" and opening it in Android Studio.
I have looked at several other questions and am trying to follow https://developer.android.com/studio/publish/app-signing.html but am having a problem creating my keystore. I have followed the tutorial verbatim but can't create a valid path for the keystone -
I don't understand what I need to do. I have tried /home/users/keystores/android.jks I have tried /home/users/keystores/myprojectname.jks and just sticking it on my desktop. These are the errors Im getting-
I have tried locating android.jks but can't find anything using finder. Is it because I am on a mac? What am I doing wrong here? How can I generate my keystore so I can publish?
/home/users/keystores/ is most likely not a valid path on your mac. Try to create the keystore in a valid location like in your user's home directory:
/home/YOUR_USERNAME/
Verify that the keystore file has been created in that location.
#skyguy You have to create a keystore first using the keytool.
The keygen tool can be accessed via command line and is already included in the JDK.
If you scroll down that link I posted in my comment above, you will see the following example -
Suppose you want to create a keystore for managing your public/private key pair and certificates from entities you trust.
Generating Your Key Pair The first thing you need to do is create a
keystore and generate the key pair. You could use a command such as
the following:
keytool -genkeypair -dname "cn=Mark Jones, ou=JavaSoft, o=Sun, c=US"
-alias business -keypass kpi135 -keystore /working/mykeystore
-storepass ab987c -validity 180 (Please note: This must be typed as a single line. Multiple lines are used in the examples just for legibility purposes.)
This command creates the keystore named "mykeystore" in the "working"
directory (assuming it doesn't already exist), and assigns it the
password "ab987c". It generates a public/private key pair for the
entity whose "distinguished name" has a common name of "Mark Jones",
organizational unit of "JavaSoft", organization of "Sun" and
two-letter country code of "US". It uses the default "DSA" key
generation algorithm to create the keys, both 1024 bits long.
It creates a self-signed certificate (using the default "SHA1withDSA"
signature algorithm) that includes the public key and the
distinguished name information. This certificate will be valid for 180
days, and is associated with the private key in a keystore entry
referred to by the alias "business". The private key is assigned the
password "kpi135".
The command could be significantly shorter if option defaults were
accepted. As a matter of fact, no options are required; defaults are
used for unspecified options that have default values, and you are
prompted for any required values. Thus, you could simply have the
following:
keytool -genkeypair
In this case, a keystore entry with alias "mykey" is created, with a newly-generated key pair and a certificate
that is valid for 90 days. This entry is placed in the keystore named
".keystore" in your home directory. (The keystore is created if it
doesn't already exist.) You will be prompted for the distinguished
name information, the keystore password, and the private key password.
The rest of the examples assume you executed the -genkeypair command
without options specified, and that you responded to the prompts with
values equal to those given in the first -genkeypair command, above (a
private key password of "kpi135", etc.)
Once you have created a keystore, you can point to its location and sign your apk.
When I run from directly eclipse it successfully work but when I export sign in application package and install exported app then it will give following errors:
invalid key hash.the hash key uR+29vKBjrnn3baLc4CBwhtmJdk does not match any stored key hash.configure your app key hashes at http://developers.facebook.com/APPID
When I put this uR+29vKBjrnn3baLc4CBwhtmJdk in release key then give error like....configure your app key hashes at http://developers.facebook.com/APPID
So what is issues here and hash key n release key different in every time?
You need to create a new Key for your application and it will be created using the Sha1 key of your signed application.The new sha1 key is generated whenever you create a new signed application.Use that sha key
During the process of signing, output similar to that outlined below will appear within the Console panel:
[2013-06-13 10:34:39 - ReleaseTest] New keystore C:\Users\nadags\Documents\AndroidReleaseAPK\ReleaseTest.apk has been created.
[2013-06-13 10:34:39 - ReleaseTest] Certificate fingerprints:
[2013-06-13 10:34:39 - ReleaseTest] MD5 : FA:65:D--------------
[2013-06-13 10:34:39 - ReleaseTest] SHA1: D1:E-------------------
or it will also appear on the popup where you will name your build finally before signing it.
Use this SHA1 to create new key at facebook developer console and include that in your app.
After you have followed the above procedure, do not right click and run the project again from eclipse, that will make the app to load from its default sha1 key. After you sign the app, manually copy paste the signed .apk to your device. That will make it work.
Note:-
For signing your app in android studio and obtaining new key,you can use THIS and THIS .
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.
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;
}