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.
Related
I am integrating gmail login in my android application by following this thread :
https://developers.google.com/identity/sign-in/android/sign-in?configured=true
But I am getting error as :
Status{statusCode=DEVELOPER_ERROR, resolution=null}
I looked through this status code documentation here :
https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult.html#DEVELOPER_ERROR
Above link does not help to diagnose the problem,
I have created the debug keystore file, & generated SHA-1 using keytool, also in Google developer console, I added package name as it is in manifest file or gradle file.
But all seems to fail can anybody tell me what does this error code suggest what may go wrong ?
Problem was SHA1 mismatch,
1] First Keystore File : I solved the error, problem was while building apk Android studio was taking default keystore file which was located inside C:\Users\<LOGGED_IN_USER_NAME>\.android\debug.keystore
2] Second Keystore File : Also I created one other keystore file which was located at different directory i.e. app/keystore/debug.keystore
While configuring the google developer console to integrate gmail login within app I gave sha-1 key generated through second keystore file above, the studio while building the apk file taking other keystore file hence sha-1 key mismatch was happening.
In order to take my keystore file located # app/keystore/debug.keystore I configured gradle file at app level with following code :
signingConfigs {
debug {
storeFile file('keystore/debug.keystore')
keyAlias 'androiddebugkey'
keyPassword 'android'
storePassword 'android'
}
/*
release {
storeFile file('release.keystore')
storePassword "mystorepassword"
keyAlias "mykeyalias"
keyPassword "mykeypassword"
}
*/
Now the generated apk sha-1 signature matches with the sha-1 key configured on google developer console for your app.
One note : Always use debug.keystore for debugging the gmail integration (At the time of development).
Refs :
For gmail integration :
https://developers.google.com/identity/sign-in/android/start-integrating
To see which sha-1 is getting used for your application see this stackoverflow thread :
SHA-1 fingerprint of keystore certificate
For anyone who is using React Native Google Signin and Firebase, try this.
Step 1: Get the SHA-1 of your Android Developer Debug Keystore
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
The password is android. Copy the SHA-1 value, which will look something like this in the output:
Certificate Fingerprints
....
SHA1: aa:bb:cc:dd:ee:ff:11:22:33:44:47:D0:9E:8D:E0:0C:79:F1:0F:CB
Step 2: Add the SHA to the Android App in the Firebase Console
Now open up your Android App in the Firebase console and add the SHA-1:
For react native app google login I followed following steps and it worked
Setup app in firebase console for iOS/Android on the following link
https://console.firebase.google.com/
Download GoogleService-Info.plist for iOS and google-services.json for Android
Don't forget to set SHA certificate fingerprints SHA1 for android setup. It's mandatory to work with Android.
Then copy Web client (auto created by Google Service) from OAuth 2.0 client IDs from following URL to access Google developer console
https://console.developers.google.com/
After doing all of these steps in firebase developer console and Google developer console
move to your code
Open your .js file from where you provide an option to login via Google.
In componentDidMount place following code
GoogleSignin.configure({
iosClientId: Constants.GOOGLE_LOGIN_CLIENT_ID_IOS,
webClientId: Constants.GOOGLE_WEB_CLIENT_ID,
offlineAccess: false
});
or you can create a separate method like this and call it in componentDidMount to configure GoogleSignIn
async setupGoogleSignin() {
try {
await GoogleSignin.hasPlayServices//({ autoResolve: true });
await GoogleSignin.configure({
iosClientId: Constants.GOOGLE_LOGIN_CLIENT_ID_IOS,
webClientId: Constants.GOOGLE_WEB_CLIENT_ID,
offlineAccess: true
});
const user = await GoogleSignin.currentUserAsync();
console.log("user from google sin in", user);
} catch (err) {
console.log("Google signin error", err.code, err.message);
}
}
After configuring GoogleSignIn you can call the following method on the press of GoogleSignInButton
googleAuth() {
GoogleSignin.signIn()
.then(user => {
console.log("user==", user);
console.log("user name = ", user.user.email);
console.log("accessTOken = ", user.accessToken);
this.props.socialMediaLogin( // this is my method that I call on successful authentication
user.user.id,
user.user.name,
user.user.givenName,
user.user.familyName,
user.user.email,
user.user.photo,
"GOOGLE",
user.accessToken
);
})
.catch(err => {
console.log("WRONG SIGNIN", err);
})
.done();
}
I just unblocked myself after struggling with this for almost 6 hours and here are my findings.
Please make sure the following:
Correct package name in Google Developer console. (Don't go with just the package name from AndroidManifest.xml. Inspect the Gradle files to see if you flavor name is being changed dynamically when building).
Generate Sha-1 Hash at the correct keystore location. (I was going with default keystore location ~/.android/debug.keystore but found out that my app was overriding with another location in the repository and hence, i was getting developer_error all along.)
PS: In case of your app uses backend server to pull data offline, create the project from the Google sign-in flow since this will generate OAuth Client id's for both Android and WebServer.
For Windows
For windows use this keytool -exportcert -list -v -alias androiddebugkey -keystore C:\Users[YOUR WINDOWS USER NAME].android\debug.keystore
Like this
keytool -exportcert -list -v -alias androiddebugkey -keystore "Your debug.keystore" Path
keytool -exportcert -list -v -alias androiddebugkey -keystore C:\Users\keshav.gera.android\debug.keystore
keytool -exportcert -list -v -alias androiddebugkey -keystore E:\HNSetup2\healthnickel\HealthNickel\android\app\debug.keystore
Password is :- android
ass your SHA1 Here Firebase Console
Note ===> update your google-service.json file in your app folder Please update
My problem was the SHA1 key in the developer console didn't match the one generated from my debug.keystore file. Run
keytool -exportcert -keystore path-to-debug-or-production-keystore -
Copy the SHA1 key and paste it into the developer console (console.developers.google.com) under your app > credentials > OAuth 2.0 client IDs > Oauth > Signing-certificate fingerprint
Another thing to watch is that newer versions of keytool (eg for Java 9) will generate a SHA-256 value, not SHA-1.
For Ionic apps with a native GoogleSignIn plug-in, try setting "Application type" to "Web application" instead of "Android" when creating the "OAuth client ID" in the Google Cloud Console.
This solved it for my Ionic capacitor app when using the #codetrix-studio/capacitor-google-auth plug-in.
In my case I was using the wrong SHA-1
In my case I was using this
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
for SHA-1.
When I used this
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
and pasted the SHA-1 in firebase console it worked
I was able to get the facebookConnectPlugin working on iOS using PhoneGap and Ionic. The issue is that when I try to run the exact same app on Android I get the error "facebookConnectPlugin is not defined". I'm using PhoneGap Build and am not building natively for Android.
Here are the steps I've taken to try to get it working on Android:
1) Generated a new keystore.
"C:\Program Files (x86)\Java\jre1.8.0_60\bin\keytool.exe" -genkey -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000
2) Created a new hash using this keystore.
"C:\Program Files (x86)\Java\jre1.8.0_60\bin\keytool.exe" -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64
Used the password "android" everywhere it asked me for a password (for the keystore and the hash).
3) Added the following to my config.xml document:
<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.9.0">
<param name="APP_ID" value="XXXXXXXXXX" />
<param name="APP_NAME" value="MyApp" />
</gap:plugin>
The APP_ID I got from Facebook and the APP_NAME was the display name from Facebook.
4) Created an Android key in PhoneGap build uploading the keystore I specified and the alias "androiddebugkey". For all the passwords, including the certificate password I input my password "android".
5) Uploaded my application to PhoneGap build, installed it on an Android emulator (Lollipop using Visual Studio Emulator for Android) and tried to log into Facebook using the following code. This code fires after $ionicPlatform.ready.
var _this = this;
var fbLoginSuccess = function (userData) {
facebookConnectPlugin.api("me/?fields=id,email", ["public_profile"],
function (result) {
},
function (error) {
alert("Failed: " + error);
}
);
}
facebookConnectPlugin.login(["public_profile"],
fbLoginSuccess,
function (error) {
alert(JSON.stringify(error));
}
);
6) For my site at developers.facebook.com I added an Android app. The Google Play Package Name is the same as my "id" in the widget element in config.xml. For the Class Name, I specified the exact same thing as the id, but with ".MainActivity" appended to it. I inserted the Key Hash generated from Step 2 above into the Key Hashes field. I turned Single Sign On on. Not sure if that is correct or not.
I've spent days trying to figure this out with no luck. I'm not sure if the issue is with the hash, cordova, or some other Facebook permissions. Like I said earlier, it works fine on iOS. It's just Android that has the problem.
Any help would be very much appreciated.
#oalbrecht,
I am posting this link with the hope you will read the entire document.
Top Mistakes by Developers new to Cordova/Phonegap
In fact your error was
3. Does not follow the blogs.
For you see, we have now move to a new repository on npm.org. This actually gets you another error
11. You need to get your plugins from NPM now.
How did I figure this out? I did a google search of your plugin: com.phonegap.plugins.facebookconnect
About three (3) links down is your plugin: FacebookConnect
The documentation says
REPOSITORY IS NOW DEPRECATED!!!
Please go here
READ THE DIRECTIONS CAREFULLY. This is an ugly plugin. The correct links are:
github
npm
Your new plugin setting is:
<gap:plugin name="cordova-plugin-facebookconnect-orlando" source="npm" version="0.11.0">
Good morning
I'm trying to build an Android application on release mode using Visual Studio Tools for Apache Cordova CTP3.1
After I create my myreleasekey.keystore using android tools
http://developer.android.com/tools/publishing/app-signing.html
I set data in ant.properties
key.store=C:\\Users\\myreleasekey.keystore
key.alias=MoayadMyro
key.store.password=password
key.alias.password=password
I got error :
Error : BLD00213 : Signing key MoayadMyro not found. Verify the alias in ant.properties is correct.
cmd: Command failed with exit code 8
Thanks
I had exactly the same problem and no matter the permutations of keystore alias I tried, I kept getting the same error in visual studio for Apache Cordova.
To resolve I simply repeated the generation process.
Generate a new key store using keytool:
C:\myChosenDir> keytool -genkey -keyalg RSA -alias selfsigned -keystore mykeystorename.keystore -storepass mykeystorepass -validity 10000 -keysize 2048
Enter the information requested as part of the keygen:
When requested to enter the password for <selfsigned> reenter the password above. Hitting return suggests it uses the same but this is what I did before and it didn't work. [This was the only thing I did different]
Add the keystore to the project:
I placed the keystore in the same folder as the ant.properties file
Update the ant properties file:
key.store=mykeystorename.keystore
key.alias=selfsigned
key.store.password=mykeystorepass
key.alias.password=mykeystorepass
[NB: preserve the line breaks can't get them to play correctly in markdown]
I know this a bit of a turn it off and turn it on again answer but it worked for me. Best of luck.
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 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.