Related
I have followed the documentation here and here (which are pretty straight forward), but the map view does not load any tiles.
I use HMS Toolkit, and the Configuration Wizard results in success. I also have set my api key, using this line in both my application class and my activity class onCreate.
MapsInitializer.setApiKey(HUAWEI_API_KEY);
Here is the device information and SDK version:
Phone model: Huawei Y7 Prime 2018
EMUI version: 8.0.0
HMS Core version: 6.1.0.305
Map SDK version: com.huawei.hms:maps:6.0.0.301
Here is the screen:
Relevant error logs:
E/HmsMapKit_MapView_151: createDelegate: creator == null
E/HmsMapKit_GrsClient_24: GRS returns empty.
E/HmsMapKit_ErrorTraceLogPusher_4: cache error trace log :
ErrorTraceLogDTO{ scenario = GET_GRS_URL_FAILED', message='GRS returns
empty, service name is com.huawei.hms.map.'}
E/HmsMapKit_ErrorTraceLogPusher_12: eventId is null or empty.
E/HmsMapKit_AuthenticateClient_27: Exception occur
com.huawei.hms.maps.foundation.client.c
E/HmsMapKit_ErrorTraceLogPusher_4: cache error trace log :
ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='060001 :
NETWORK_ERROR'}
E/HmsMapKit_AuthenticateCache_0: authenticate error, throw
RetryException.
E/HmsMapKit_CopyrightDelegate_27: get copyright statement html data
failed: htmlData = null
E/HmsMapKit_TileCache_38: startUrlRequest Identity fail, do not has
permission get tile. authResult :060011
PS: I have the exact same problem with this demo.
First you may refer to this Docs to see if there's an error code.
The official demo also runs incorrectly. so there is a high probability that the problem is caused by a signature or API key problem.
Please check as follows:
Check whether the Map Kit API is enabled in AppGallery Connect. If not, enable it, download the .json file to replace the existing one in the code, and then check whether the SHA256 fingerprint is correct.
In the Map SDK 5.0.0.300 or later for Android, you must set an API key before initializing the map.
(1) Set the API key in the entrance class of your project.
// In the entrance class (inherited from android.app.Application) of the app,
// call the setApiKey method in the overridden onCreate() method.
public class MyApp extends Application {
#Override
public void onCreate() {
super.onCreate();
// Set the API key.
MapsInitializer.setApiKey("Your API Key");
}
}
(2) Set the API key in Fragment or MapView.
#Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "onCreate: ");
super.onCreate(savedInstanceState);
// Set the API key before calling setContentView.
MapsInitializer.setApiKey("Your API Key");
setContentView(R.layout.basic_demo);
For details about different causes of this problem, You could aslo refer to this answer.
You need to generate and upload to AppGallery Connect two SHA-256 keys, one for debug version and one for release.
for generating key for debug version you need to:
open cmd
run command cd [path to directory with keytool.exe file]
for example: cd C:\Program Files\Java\jdk1.8.0_301\bin
run command keytool -list -v -keystore [path to debug.keystore]\debug.keystore -alias androiddebugkey -storepass android -keypass android
copy SHA-256 key and add it to AppGallery Connect -> Project Settings -> App information -> SHA-256 certificate fingerprint
for release version do everything the same, but replace the path to the key for signing the release build in 2 step and enter real release alias and password in 3 step
I try to implement Google login in my Firebase connected Android app.
When I run the app and press Google Sign In button - nothing happen. And I receive this error in onActivityResult:
Status{statusCode=DEVELOPER_ERROR, resolution=null}.
My code looks like this:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE_GOOGLE_LOGIN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()){
GoogleSignInAccount account = result.getSignInAccount();
String emailAddres = account.getEmail();
getGoogleQAuthToken(emailAddres);
}
}
}
private void getGoogleQAuthToken(final String emailAddres){
AsyncTask<Void,Void,String> task = new AsyncTask<Void, Void, String>() {
String errorMessage = null;
#Override
protected String doInBackground(Void... params) {
String token = null;
try {
String scope = "oauth2:profile email";
token = GoogleAuthUtil.getToken(MainActivity.this, emailAddres, scope);
} catch (IOException transientEx) {
errorMessage = "Network error: " + transientEx.getMessage();
} catch (UserRecoverableAuthException e) {
Intent recover = e.getIntent();
startActivityForResult(recover, MainActivity.REQUEST_CODE_GOOGLE_LOGIN);
} catch (GoogleAuthException authEx) {
errorMessage = "Error authenticating with Google: " + authEx.getMessage();
}
return token;
}
I've added JSON config file in app/ directory and added dependencies:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:1.5.0-beta2'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.+'
compile 'com.firebase:firebase-client-android:2.3.0+'
/* For Google Play Services */
compile 'com.google.android.gms:play-services-safetynet:8.3.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services:8.3.0'
compile('com.afollestad.material-dialogs:core:0.8.3.0#aar') {
transitive = true
}
/* Firebase UI */
compile 'com.firebaseui:firebase-ui:0.2.2'
compile 'com.android.support:cardview-v7:23.1.+'
compile 'com.android.support:recyclerview-v7:23.1.+'
compile 'com.android.support:design:23.1.+'
}
apply plugin: 'com.google.gms.google-services'
I am looking for solution hours already...
Please help!!
DEVELOPER_ERROR means Google Play services was unable to find a matching client from the console based on your SHA1 and package name. You can add SHA1s in the settings page on the Firebase console for a given package name, or add a new package name through the Add Firebase to your Android app button.
In general, some things to check for:
Make sure your package name is what you expect - e.g. its the one in your build.gradle, and its not being overriden in a build variant or product flavor.
Make sure you have registered your debug and release SHA1 keys in the console.
If Google Play App Signing is enabled for your app, then it will replace your release signing key with the one on Google's server before publishing.
You can check if it is enabled from: Google Play Console -> Release Management -> App Signing.
In my case, to resolve the error I had to:
copy the SHA1 from the 'App signing certificate' section
add it to the Firebase projects general settings section
regenerate the json file
add it to the project
re-upload the apk
Error code 10 is constant value of CommonStatusCodes.DEVELOPER_ERROR which implies you have misconfigured your project
What you can do
check if SHA from PlayStore Console and Firebase Console are same.
Copy SHA from Google Play console
paste it into Firebase Console
What else you can do?
Display meaningful messages in plain English case of failure
// Google Sign In failed, update UI appropriately
Log.w(TAG, "Google sign in failed", e);
String messageToDisplay = "Authentication failed.";
switch (e.getStatusCode()) {
case CommonStatusCodes.API_NOT_CONNECTED: //17
messageToDisplay += "The client attempted to call a method from an API that failed to connect.";
break;
case CommonStatusCodes.DEVELOPER_ERROR: //10
messageToDisplay += "The application is misconfigured.";
break;
case CommonStatusCodes.ERROR: //13
messageToDisplay += "The operation failed with no more detailed information.";
break;
case CommonStatusCodes.INTERNAL_ERROR: //8
messageToDisplay += "An internal error occurred.";
break;
case CommonStatusCodes.INVALID_ACCOUNT: //8
messageToDisplay += "Invalid account name specified.";
break;
case CommonStatusCodes.SIGN_IN_REQUIRED: //8
messageToDisplay += "Please Sign In to continue.";
break;
}
Toast.makeText(LoginActivity.this, messageToDisplay,
Toast.LENGTH_SHORT).show();
I had the same problem. What happens is this you have a SHA1 debug and release SHA1. Normally we used only SHA1 Debug and generate the .apk signed to google play, but when we use google sigin you must enter the firebase release of SHA1.
To view the release SHA1 use the following command:
keytool -list -v -keystore C:\ProjectsData\keystore\my-release-key.keystore -alias alias_name
Then enter this SHA1 on the Firebase
https://support.google.com/firebase/answer/7000104
This answer SHA1:
SHA-1 fingerprint of keystore certificate
Hope I helped you.
Had the same issue. But worked fine after I cleaned and rebuilt the project. :D
I created new debug SHA1 key using following steps and replaced SHA1 key in my project settings. it worked for me.
-Open Your Project.
-Click on File menu -> New -> Click on Google -> Select Google Maps Activity -> Click on Finish.
-Android studio would generate automatic google_maps_api.xml file.
-You can get debug SHA1 key in this file.
Replace this SHA1 key in project settings, Then download new google-services.json from settings and replace it in your project as your certificate_hash and client_id will change.
I had the same issue and I got it working by doing these steps:
1. Add DEBUG_KEYSTORE SHA1 fingerprint to the firebase project. use the following command(MAC/LINUX)
keytool -exportcert -list -v \-alias androiddebugkey -keystore ~/.android/debug.keystore
2. Now Generate a signed apk of your project. The process includes generating a keystore for your app's release version. Copy the path of the newly generated .jks file.
3. Now generate RELEASE_KEYSTORE SHA1 fingerprint using the following command
keytool -list -v -keystore FULL_PATH_TOJKS_FILE -alias ALIAS_NAME
4. Copy the new SHA1 from the output and add it as another SHA1 fingerprint in your firebase application console.
Now you are good to go! ---- Hope! it helps.
After spending two hours on this. Trying out everything mentioned here and on this github issue. I still got the same developer error.
What worked for me is to force android studio to use a new debug signing key and add the new key to firebase console.
When you generate the signingReport in android studio it also print where your keystore is located. Something like:
> Task :app:signingReport
Variant: debug
Config: debug
Store: C:\Users\<Username>\.android\debug.keystore
Alias: AndroidDebugKey
MD5: E0:....
SHA1: DD....
SHA-256: B2:81....
Valid until: Thursday, 23 March 2051
----------
I renamed the debug.keystore to debug.keystore_ and the lock file also. Then I did a clean and rebuild in android studio. It automatically created a new keystore. Use the signingReport again and add the new key to the firebase console project.
This solved the issue for me.
Note: To double check the package name of the debug apk. Use the aapt2 tool: https://developer.android.com/studio/command-line/aapt2
By default, it was located in the android-sdk\build-tools\<version>\aapt2.exe path for me.
aapt2 dump packagename <projectpath>\app\build\outputs\apk\debug\app-debug.apk
Though it was the same for me as the manifest and the build.gradle one.
I think you need to change your play-service version.
See Firebase Android Codelab to add Firebase Auth dependency to your app/build.gradle file.
Try to update your play-service in gradle as below:
/* For Google Play Services */
...
compile 'com.google.android.gms:play-services:9.0.0'
...
DEVELOPER_ERROR :
The application is misconfigured. This error is not recoverable and will be treated as fatal. The developer should look at the logs after this to determine more actionable information.
While creating the OAuth key, you need to make sure you are giving correct package name. This means the package name that comes in your manifest file.
If you are using multiple modules (e.g. some library like FirebaseUI-Android), then make sure while creating the key, you use the package name from which you request Google authentication.
I had the same issue. After 2 days of pain, I observed that my release SHA1 was incorect (I used to get it using the keytool in java/bin and it gave me a bad SHA1. Probably because now Android Studio uses its own java package and not the JDK). Better way to get the corect SHA1 here SHA-1 fingerprint of keystore certificate
Click Here (Google Developer guide line) and create new project for Firebase console
this link is set with default setting, so you don't need to add it manually
If your app is on release mode/production, then you have to get the SHA1 from your-release-store.keystore. If your app is on development mode, then you have to get the SHA1 from your-debug-key.keystore. Copy all the SHA1 to your Firebase project settings > add fingerprint.
This is how to get the SHA1 from your keystore file:
keytool -exportcert -keystore ~/pathtoyourkeystore/yourfile.keystore -list -v
I am usign gplus sign in, and getting this error at time I am in onActivityResult....
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
client.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
// Log.d("Result","details"+ acct.getDisplayName() + acct.getEmail());
mEmail = acct.getEmail();
String mFullName = acct.getDisplayName();
String mGoogleplusId = acct.getId();
SocialUser user = new SocialUser();
user.setType("googleplus");
user.setEmail(mEmail);
user.setFullname(mFullName);
user.setId(mGoogleplusId + "");
loginParams.put("email_id", mEmail);
loginParams.put("googlePlusId", mGoogleplusId);
loginParams.put("full_name", mFullName);
loginParams.put("registrationType", "googleplus");
SignUpService(user);
} else {
Toast.makeText(CustomerLogIn.this, "Unable to fetch data, Proceed manually", Toast.LENGTH_SHORT).show();
}
}
}
And I am calling for gplus login on button click. On clcking button following code is executed....
GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(CustomerLogIn.this)
.addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, 0);
And I am geetng this error...
Status{statusCode=DEVELOPER_ERROR, resolution=null}
on this line....
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
Please suggest the solution.
You need to add your SHA1 key to firebase console configuration.
You can do it in this way:
Firebase console ( https://console.firebase.google.com ) -> your project -> configuration -> scroll to
You can find your SHA1 key running "Signing report" from Android Studio:
Then, look the "run tab" and click the button:
I think it's the easier way. Hope this help.
Probably you created the configuration file using the SHA1 of your production token, use the androiddebugkey alias to gather the SHA1 corresponding to the debug version of your app and copy the configuration file to the 'app' directory, you should have both configuration files (one for debug purposes and another for production environment).
Based on the walkthrough published in https://developers.google.com/identity/sign-in/android/start
The way I fixed it was by picking up the key corresponding to the highlighted text. Due to the confusing usage of the word 'server' in Firebase's documentation page I was picking up the Server key . Which was the reason for the problem.
You can find the key here.
I had the same issue and I got it working by doing these steps:
1.Add DEBUG_KEYSTORE SHA1 fingerprint to the firebase project. use the following command(MAC/LINUX)
keytool -exportcert -list -v \-alias androiddebugkey -keystore ~/.android/debug.keystore
2.Now Generate a signed apk of your project. The process includes generating a keystore for your app's release version.
Copy the path of the newly generated .jks file.
3.Now generate RELEASE_KEYSTORE SHA1 fingerprint using the following command
keytool -list -v -keystore FULL_PATH_TOJKS_FILE -alias ALIAS_NAME
4.Copy the new SHA1 from the output and add it as another SHA1 fingerprint in your firebase application console.
Now you are good to go! ---- Hope! it helps.
I was having the same problem, how I solved it is that I had different applicationId in my gradle file than the package name in my manifest file. And I used to applicationId to create the json file. I had to change my package name to what my applicationId was and that fixed it for me.
Alternatively to the answers provided here, you can use Android Studio's Firebase Assistant to automatically add your SHA-1 to your project with the click of some buttons.
In Android Studio, go to Tools > Firebase > Select 'Authentication' and click the link that says 'Email and password authentication'.
This will bring you a little tutorial on how to integrate Authentication to your project, but since you've probably done all that, just click 'Connect to Firebase' and you're done.
It's an old question, but I have been stuck with error 10 (DEVELOPER_ERROR) lately, because I was using the Android client ID, I created in the google developer console.
The solution for me was to use the Android credentials in google developer console only to indicate the SHA key of my apk and to use the client ID of the Web application (!) credentials from the google developer console in my cordova application.
config.xml:
<plugin name="cordova-plugin-googleplus" spec="^5.3.0">
<variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.[web-application-client-id]" />
<variable name="WEB_APPLICATION_CLIENT_ID" value="[web-application-client-id].apps.googleusercontent.com" />
</plugin>
code:
window.plugins.googleplus.login(
{
'webClientId': '[web-application-client-id].apps.googleusercontent.com'
},
...
I don't use firebase.
You might have generated and added wrong SHA1 key. Use following steps to generate SHA1 key in Android studio:
Click on Gradle (From Right Side Panel, you will see Gradle Bar)
Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)
Click on Your Project (Your Project Name form List (root))
Click on Tasks
Click on Android
Double Click on signingReport (You will get SHA1 and MD5 in Run Bar(Sometimes it will be in Gradle Console))
Now add this SHA1 key in your firebase android project.
Please Put correct json file in root of the android project
For more Refer here: https://coderzpassion.com/android-working-latest-google-plus-login-api/
The error is caused because the SHA-1 checksum of the debug or release key is not included in the firebase/google console.
First generate key using following command:
keytool -list -v -keystore KEYSTORE_PATH -alias ALIAS_NAME
Then copy the SHA-1 checksum and go to:
Firebase Console > Your project > Settings of the app > Add Fingerprint
For me it was working when I first implemented it, but stopped after a few days of development, with the mentioned error message.
I've solved the issue with these steps:
I have added the sha-256 fingerprint on top of the sha-1 fingerprint that I already had in the firebase console. (Not sure if this step is required)
I have downloaded google-services.json file again and replaced the old file.
re-installed the app
and it worked
Check below steps
Make sure you use correct SHA keys
Use web client id, not android client id while requesting id token
I came across this error in my firebase app.
It was fixed when I added therequestIdToken(activity.getString(R.string.default_web_client_id)) part below.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail().requestIdToken(activity.getString(R.string.default_web_client_id))
.build();
apiClient = new GoogleApiClient.Builder(activity)
.addConnectionCallbacks(this)
.enableAutoManage(activity, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(apiClient);
activity.startActivityForResult(signInIntent, RC_GOOGLE_SIGN_IN);
I got this error when i updated my json config file with a new google account.
Uninstalling the application manually and reinstalling the app worked for me.
For anyone releasing an app, you need a special fingerprint from your keystore file. No wonder why I was getting this error just for the release version. How to obtain Signing certificate fingerprint (SHA1) for OAuth 2.0 on Android?
Ensure you enable Google Sign-In in under Authentication in the Firebase console.
I solved my problem by use right server_client_id in this line :
String serverClientId = getString(R.string.server_client_id);
I used the wrong code.
Some Services like google login require SHA1 fingerprint to be added to your firebase console.
I missed adding SHA fingerprint in firebase console. You can do so by going in FireBase Console > project setting > Add fingerprint option.
You can generate SHA1 Fingerprint by a very easy way https://www.youtube.com/watch?v=FczARQ244GE
After that I was doing one more mistake
After generationg SHA1 key fom above method. I copied the wrong invalid SHA1 key which was an expired one. So make sure the SHA1 key that you are copying from above way output is a valid one (Check the valid untill value as well of SHA1 Key)
Also make sure that the package name(x.y.z) that you have added in firebase is same as used in your android code.
Also make sure to use correct AppID
After long invistigation I have found a solution. Actually this error Error: Status{statusCode=DEVELOPER_ERROR, resolution=null} points to incorrect SHA-1 OR Incorrect package name OR something else?. In my case, I add debug keyword to end of my package name com.sample.app => com.sample.app.debug
I struggled with this issue because I made a copy of my application with changing the package name.
I add a new project for it at Firebase.
My mistake was that I forgot to change the server's client ID to the one in the new Firebase project.
more details under authintication with Firebase sectoin here
When you let Google manage your app signing, you can find the SHA-1 key in the Google Play console.
On the sidebar menu look for 'Configuration -> App integrity'. Here you will find the SHA-1 key for the signed app.
You also see the SHA-1 key for the signed app you've uploaded to the store.
don't forget to add release finger print. the former answers tell just add debug finger print which your problem just solve when you run your app in debug mode. if you release your app you can see that your problem is still remain . then make sure you added release finger print too .
If you're running into this issue with a released version (production):
Go to the Google Play console and copy SHA-1 key from Release -> Setup -> App Integrity
This also might happen if you are working with app versions deployed from "Internal App Sharing"
There is yet another certificate generated for you, and you'll need to registered it's SHA-1 fingerprint on Firebase or GCP too
with new android updates, this has started happening on a lot of my projects. The fix that worked for me was to define signconfig for both debug and release version in the gradle file and use it in build types.
In one of my project release build was working fine but dev build was facing this error.
signingConfigs {
debug {
storeFile file('/Users/user/.android/debug.keystore')
storePassword 'android'
keyPassword 'android'
keyAlias 'AndroidDebugKey'
}
release {
storeFile file('/Users/user/Development/your_key')
storePassword 'your_pass'
keyAlias 'your_alias'
keyPassword 'your_pass'
}
}
buildTypes {
release {
minifyEnabled true
debuggable false
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
debuggable true
signingConfig signingConfigs.debug
}
}
I'm trying to get a user token ID using the new Google play services 8.3
and as documented I pass the server ID:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.server_client_id))
.requestEmail()
.build();
but I'm still getting un successful result as below:
{statusCode=unknown status code: 12501, resolution=null}
and documented here GoogleSignInStatusCodes
The sign-in was cancelled by the user. i.e. the user cancelled some of the sign-in resolutions, e.g. account picking or OAuth consent.
Constant Value: 12501
That is not my case, as I already picked an account. Any idea what could be the reason?
I had exactly the same problem and i have found the solution.
If you follow the documentation found here:
https://developers.google.com/identity/sign-in/android/start-integrating
The first step tells you to create the configuration file (which creates an OAuth 2.0 client ID for you and inserts it into the google-services.json)
Then later, it says again about creating a OAuth 2.0 client ID, but this time it says that you have to do it for Web application
And this is the confusing part! (at least for me) because i was just taking the client id created for the android OAuth and not creating a new one for Web application (I thought the documentation was just redundant or something)
As it says, it is this one, and only this one the one you have to use as a parameter of the methods requestIdToken or requestServerAuthCode.
Forget about using the Android OAuth ID in this methods because then you will get all the time the ugly status code response 12501.
I think the main problem is that the documentation is a bit confusing about this. Or maybe because it is a bit strange the fact that you have to create two OAuth IDs.
So as a summary, you need TWO OAuth IDs, one for android and one for web application, and you have to set each one in the correct place.
I was struggling with this and wasted almost a week in it.
This is how I got it worked.
Import Project in AndroidStudio
Create debug keystore for project.
Create SHA1 signature for project using debug keystore.
Using SHA1 signature, register your app for Google Signin on Google Developer Console.
Generate a Google Configuration file there.(Put in Android Studio's app folder)
Use Web Client ID from OAuth 2.0 credentials in your Android Project.
Now, from Android Studio, generate debug build(APK) of your project.
Mount the device in your system -> copy this signed debug version of APK and install it.
Last three steps 6, 7 and 8, are what you actually need to take care of. If you directly run the project then APK is not actually signed with the debug keystore and google does not recognise it at all.
I had the same problem, after research solution it's resumed that server_client_id contained some incorrect value or your google_services.json didn't include oauth_client with client_id that registered with your keystore.
requestIdToken(getString(R.string.server_client_id))
R.string.server_client_id use OAuth 2.0 client ID for Web Application. And OAuth Client ID for Android use in google_services.json
Usually we use 2 keystore, 1 using debug keystore and 1 using signed keystore for published. So if we want to need in debug & publish mode, register your OAuth Client ID for Android twice, 1 using SHA1 from debug keystore and 1 from signed keystore for published.
small example in my google_services.json
"oauth_client": [
{
"client_id": "xxx-client-id.com",
"client_type": 1,
"android_info": {
"package_name": "com.app.android",
"certificate_hash": "xxxhash"
}
},
{
"client_id": "yyy.client-id.com",
"client_type": 1,
"android_info": {
"package_name": "com.app.android",
"certificate_hash": "yyyhash"
}
}
],
I was getting the same issue, it was because I created client ID of application type Android
Instead, I deleted it and created client ID of type web application and I got rid of this issue.
Just figure out how to solve this... I was getting this error while trying to run the debug version of my app... To fix it, add a credential for your debug app on the developer console and also on the google-services.json.
this fixed it for me!
I had the same problem, and I solved with the following solution:
Create configuration file (google-services.json) as described here and place in your /app project directory
(As mentioned in other answers) Using Web application Client ID for requestIdToken method.
[My main problem] Sign your app if you work on debug mode like below:
signingConfigs {
release {
storeFile file("myreleasekey.keystore")
storePassword "password"
keyAlias "MyReleaseKey"
keyPassword "password"
}
}
buildTypes {
release {
...
}
debug {
...
signingConfig signingConfigs.release
}
}
Now I got it.
So first you must follow the upper answers saying:
create a OAuth client-id for web applications in the Google Developers Console and use it in requestIdToken()
(get rid of status code 12501)
if you created a Android OAuth client-id for your production hash key, create a new Android OAuth client-id for your debug hash key and integrate it into your google-services.json.
(get rid of status code 12500)
No longer valid
And here comes the last Part:
3. you can not call requestIdToken() and requestEmail() at once. At least in my case I got rid of Result: Status{statusCode=INTERNAL_ERROR, resolution=null} by deleting requestEmail().
So good luck...
In my case, I also had to check that the debug SHA-1 was added as a valid OAuth Android client.
Use Web application as server_client_id not Android application
I had the same problem and I noticed that 12501 code was returned when my server_client_id contained some incorrect value.
Since there is no detailed message and the documentation of this error code is rather poor I don't know if your problem has the same cause as mine.
My application is based on Android code from this example (class IdTokenActivity).
To make it work I also needed to integrate Google sign-in into my app:
generated json config file with enabled Google Sign-In
added Google plugin and dependency to my gradle file
created OAuth client ID for this app and saved it in my project as server_client_id
Is your apk in debug mode? I think it only works with a signed apk.
Follow the ambiguous google's document.
Put google-services.json to your project directory
Set your gradle as https://stackoverflow.com/a/35216421/5886475
Set server_client_id in string.xml .It's your web client id not android client
A problem I had is that the SHA-1 I generated as with the incorrect alias.
The alias MUST BE androiddebugkey .
So I have put the Android OAuth ID at my google-service.json file. I have put the Web Client Id to requestIdToken().
And in my specific case, I generated the SHA-1 with androiddebugkey alias.
google-services.json:
"oauth_client": [
{
"client_id": "ANDROID OAUTH ID-.....apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "br.com.packagename",
"certificate_hash": "SHA-1 HASH"
}
},{
"client_id": "WEB CLIEND ID......apps.googleusercontent.com",
"client_type": 3
}
]
Signing part:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken("WEB CLIEND ID......apps.googleusercontent.com")
.requestEmail()
.build();
In place of R.string.server_client_id , just use R.string.default_web_client_id .
When you copy the google-services.json file into the app, it creates this string value automatically. You don't need to copy the key from google-services.json to string.xml
It worked for me.
I solved this issue by Clicking Firebase Support in Android Studio, which may not be relevant to non-Firebase users.
Go to menu Tools->Firebase
Click Connect your app to Firebase, it will display as Connected in green once connection is successful
Click Add Firebase Authentication to your app button, it will also turn green.
NOTE: Having huge list of answers in this definitely confirm one thing. Google needs to update and keep the documentation fool proof.
If none of the above options work, do check whether you applicationId in app build.gradle is same as you package name.
Oviously first check your release sha1 key is correct or not. But if still it is not working and you ar using google play services 8.4.0 (i.e.compile 'com.google.android.gms:play-services:8.4.0'), the issue could be solved by modifying GoogleSignInOption object.
Instead of:
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken("YOUR_WEB_API_ID.apps.googleusercontent.com")
.build();
You have to use :
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestScopes(new Scope(Scopes.PLUS_ME))
.requestEmail()
.build();
This solves error returning statusCode=INTERNAL_ERROR OR statusCode=Error 12501 OR statusCode=Error 12500.
Then this gso object could be used for creating GoogleApiClient as shown below:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API,gso)
// .addApi(Plus.API, null)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
// .addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
Don't know why but SHA1 in android studio is changed automatically and that's why I am getting this error. To solve this I updated the SHA1 of my firebase project settings with the new SHA1 of my android studio and it started working again.
In my case, my Credentials for Client ID for Android on Google APIs Console only contained the SHA-1 for my release signed APK. Android Studio was using the default debug keystore to sign my debug builds, and in that case the debug keystore SHA-1 did not match the Android client SHA-1 online. My solution was to simply sign the debug builds with the release keystore.
In Android Studio, Build/Edit Build Types..., then select your debug build type and make sure Signing Config is set to your release certificate.
Try following these steps:
Clone the following project https://github.com/googlesamples/google-services
Follow the guide at https://developers.google.com/identity/sign-in/android/start
Use Web client (auto created by Google Service) and add it in requestIdToken(...)
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken("YOUR_WEB_API_ID.apps.googleusercontent.com")
.build();
Make sure you are using the same keystore used which is added to Google project. For instance, if you have used the following command to generate SHA-1 key
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
Then add the following code in app/build.gradle file inside android { ... } [Solved my problem]
signingConfigs
{
debug
{
storeFile file("/home/ashwin/.android/debug.keystore")
storePassword "android"
keyAlias "androiddebugkey"
keyPassword "android"
}
}
buildTypes
{
release
{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug
{
signingConfig signingConfigs.debug
}
}
Note: Your keyPassword and keyAlias should be the same used during generation of SHA-1 certificate.
If you are using the debug keystore to build the project, you need to add the SHA-1 fingerprint of debug.keystore on Firebase Console.
On your Firebase Console, open your Project
Go to Parameters. Tab General
At the end of this page, there is a field to add a Fingerprint SHA-1
Paste the SHA-1 in the console field.
To obtain SHA-1 of debug.keystore :
Mac/Linux :
keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
Windows :
keytool -exportcert -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore
https://developers.google.com/android/guides/client-auth
That's all !
I had the same problem and error 12501 and non of of above did work for me.
My problem was I using google Default web api that generated for me. after creating my own web api error disappeared and worked fine!
these are working steps:
first I created SHA1 debug key and add to Firebase console. creating SHA1 from here.
create both web api and android OAuth 2.0 client ID from here
get generated google-service.json from Firebase console and put in app folder.
put this code for GoogleSignnOption
like this:
gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken
("put the web app client Id that get from the link in developer console ")
.requestEmail().build();
tip 1: I find out that you should create both android and web app Client Id to work.
tip 2: if you from Iran like me you can get the user from google but you can not AuthWithGoogle and result will fail in auth.signInWithCredential(credential) and you had to use some proxy for returning true.
this is the working full source of FireBaseAuthDemo in github:
hope help full
I had this problem too, after following Google's instructions for Automatically signing your app. If you are using this method to sign your apps, you will need to include the generated keystore fingerprint in your API credentials.
On the project browser, right click on your app and select Open Module
Settings.
I found it less confusing to put the .jks file in my project's /app directory. In any case run this line on it.
keytool -list -v -keystore /home/user/keystores/android.jks
You will be prompted for a password. Not sure if it's the Key Password or Store Password because mine are the same. :|
The console will spit out a bunch of certificate fingerprints. Take the SHA1 one and punch it into your API credentials at the Google API Developer's Console. You will need to enter it for the Android client OAuth 2.0 client IDs even though you don't actually use that client_id in your app. If you are using other APIs for android, put the same SHA1 in the appropriate key credentials under API keys too.
Here is a new one. I was trying for 6 hours to login on the emulator with the id from my corporate Google Apps domain, to no avail, getting 12501 errors. On a hunch, I tried my personal gmail id and it worked. Ditto if I tried on my phone with my corporate id. It turns out the emulator did not have the proper Mobile Device Management settings to allow my corporate id to login.
So If I want to test on the emulator with this corporate id, I have to install Google Play Store, then the MDM software, and configure it.
From my weird experience with this error, I can say that you also need to try to reboot your phone in order to get rid of this error :)
I was implemented Google Sign In using G Suite accounts which have a device policy assigned via Google Admin. So on the first sign in it was requiring to install Device Policy app. After all later steps completed, it was just throwing 12501 error. Same time the same app was working fine on other phones. So only reboot helped. But helped
Though already many upvoted answers exist in this question, I struggled to understand the logic.
So, I come up with my research.
Create a app using correct package name & Signing-certificate fingerprint SHA-1 https://developers.google.com/mobile/add?platform=android&cntapi=signin
Enable google sign-in
Generate the configuration file.
To get SHA-1, run this in terminal:
keytool -exportcert -keystore path-to-debug-or-production-keystore -list -v
About OAuth 2.0 client IDs
OAuth for the web (In app this is used as server_client_id)
OAuth for android (This needs to be created using correct package name & Signing-certificate fingerprint SHA-1).
If you are using the different keystore for debug & release, you need to create separate OAuth 2.0 client IDs using respective package name & SHA-1.
You can create or edit your OAuth 2.0 client IDs here https://console.developers.google.com/apis/credentials?project=
Navigating to your app.
If you already have a OAuth for Android, click in its name & check the package name & SHA-1.
We can use the same keystore for both debug & release by saving the keystore details in global(local, not inside project) gradle.properties & getting it in build.gradle as below.
def key_alias = ""
def key_password = ""
def store_file = ""
def store_password = ""
try {
key_alias = YOUR_KEY_ALIAS
key_password = YOUR_KEY_PASSWORD
store_file = YOUR_KEYSTORE_PATH
store_password = YOUR_KEYSTORE_PASSWORD
} catch (Exception exception) {
throw new IllegalStateException('Failed to find key store details. Social Login is disabled');
}
android {
signingConfigs {
config {
keyAlias key_alias
keyPassword key_password
storeFile file(store_file)
storePassword store_password
}
}
buildTypes {
debug {
signingConfig signingConfigs.config
// ...
}
release {
signingConfig signingConfigs.config
// ...
}
}
}
You can use below snippet
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_GOOGLE_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// ...
} else if (result.getStatus().getStatusCode() == CommonStatusCodes.NETWORK_ERROR) {
// No internet connection
} else if (result.getStatus().getStatusCode() == CommonStatusCodes.DEVELOPER_ERROR) {
// Wrong server OAuth key(server_client_id)
} else if (result.getStatus().getStatusCode() == 12501) {
// Wrong app signing-certificate fingerprint SHA1
} else {
Log.e("Google sign in error", result.getStatus().toString());
}
}
}
Note: If you enabled only Google Sign-In when you generated the configuration file, you need not to add the google-servies.json file in your project.(generating the file performs the necessary configuration steps).
1.Specify signingConfigs in your gradle file
signingConfigs {
config {
keyAlias 'appalias'
keyPassword 'hunter123'
storePassword 'hunter123'
storeFile file('path/to/keystore.jks')
}
}
2.Go to Build Types in Project Structure (in Android Studio) and specify signingConfigs to "config"
Now clean your project and build again. It should work.
If the above doesn't work then below is your last resort.
Try step one and build and check. If it's not working go to next step and try to build again.
Build a signed apk (With remember password checked).
Before signing check the filename of the keystore file and the one yo give in while signing the apk (in android studio).
Install the signed apk in your device.
Wait for five minutes.
Try singing in to google. If still 12501 is coming wait five more minutes. While doing that hit gradle sync.
Try again. It should work.
I have same problem too, Was resolved as follows:
I was made to delete the SHA1 previously thought and create and set new SHA1.
generate new google-services.json and set into my app directory
I was use exactly google developer codes
my result.isSucces() returned true after running the project
as summary, delete old sha1 and create new sha1 and download new google-services.json
I was facing the same 12501 status error. This is due to SHA-1 mismatch of release APK and debug APK.
Make a signed APK. To sign an APK, choose existing path of the keystore you have used for creating SHA-1. e.g. /.android/debug.keystore
Give alias-name : androiddebugkey
storepass and keypass : android.
I have developed lib to Add Google SignIn option in your app with just few lines of code. Try HiGoogle- Google SignIn Made Easy
Use Web application as server_client_id not Android application. Pass it in the HiGoogle constructor.
I want to automatically set different android map api V2 keys for development and production.
Log in to Google APIs Console
Under "Simple API Access" click "Edit Allowed Android apps..." on the right side
Enter one SHA-1 fingerprint per line like the instructions say:
"One SHA1 certificate fingerprint and package name (separated by a semicolon) per line. Example:
45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:12:17:F2:56:26:A0:E0;com.example
45:B6:E4:6F:36:AD:1A:98:94:B4:02:66:2B:12:17:F1:56:26:A0:E0;com.example"
Now, just use the same "Simple API key" and it'll work for your debug and publish certificate without having to change anything.
I may be wrong, but I think you can use the same V2 API key for both development and production builds. In your Google APIs Console, after generating a simple Android key, you just need to enter the SHA-1 fingerprints of your production signing key, and all the development Android debug signing keys you may have. Then in your manifest, just use that simple Android key and the app should work for both debug and production builds.
One of the easiest solution.You can achieve it with two simple steps.
Add custom value to manifestplaceholders build.gradle file.
See below
buildTypes {
debug {
manifestPlaceholders = [ mapApiKeyValue:"GHjaSyAjlyp3O831lgaonHMXsd-_DpQ3002x3S4"]
}
release {
manifestPlaceholders = [ mapApiKeyValue:"AIzaSyAuMGDLr2HeuRed4JA0CrdYYdZRjeC3EA"]
}
}
Edit manifest file like below.
part of my manifest file
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="${mapApiKeyValue}" />
This solution works for the latest Android 5.0 and Android 6.0 (API 20, 21,22,23)