42

I am trying to integrate a Google plus Login in my application as per the instruction provided by following link : https://developers.google.com/+/quickstart/android#install-sdk

I am following all the instructions perfectly. And when I run the sample application on a real device provided in the android-sdk and click the signin button, it display a Toast message that An internal error occurred

What am I doing wrong?

Geek
  • 8,280
  • 17
  • 73
  • 137
Hardik Nadiyapara
  • 2,436
  • 2
  • 17
  • 24

20 Answers20

86

I have this problem and even after creating 10 different client IDs with different SHA and package name, it doesn't work... until I found out that you have to fill the Consent screen.

According to GoogleDevelopers Console -

The consent screen will be shown to users whenever you request access to their private data using your client ID.

Consent screen

mihirjoshi
  • 12,161
  • 7
  • 47
  • 78
  • And Google is just too busy on complex and missing the basics! – Muhammad Babar Sep 15 '14 at 07:40
  • Two mandatory things to set in consent screen: Email and Product Name. – hasan Feb 16 '15 at 10:57
  • I have filled out this consent screen but I am not getting a popup of any kind in my Android app with a consent form. Am I missing something? Should the app be displaying a popup with the consent form? – Max Worg Mar 01 '15 at 13:24
  • Nevermind - I had to create two Client IDs (one for apps signed with the release key and apps signed with the debug key). Once I added both of these SHA fingerprints for both keys in the Developer console the error went away and all was well in the land. – Max Worg Mar 01 '15 at 14:02
31

This can happen when you haven't set the signature for the client ID in your API console project, or if you copied the wrong key value from keytool. Doing so is documented in the steps of the quick start guide on steps 7, 8, 9, and 10.

Vic Fryzel
  • 2,395
  • 16
  • 20
  • 4
    I am also generate (fingerprint)SHA1 using my own production key store. but unfortunatly error not gone :( – Hardik Nadiyapara Apr 16 '13 at 10:11
  • Which android support lib are you including? – Vic Fryzel Apr 17 '13 at 14:35
  • 1
    Hey @HardikNadiyapara i am generating right but still i got same error – Tofeeq Ahmad May 09 '13 at 05:01
  • @Sameer are u using production keystore or debug keystore for testing? – Hardik Nadiyapara May 09 '13 at 05:17
  • 2
    I am facing the same problem. For the sample app with its debug key SHA fingerprint there is no problem, but when I try to use the same method on my app using its own production key SHA fingerprint, it fails. Of course I have created the Client ID for my own app with its own fingerprint and package name, instead of those for the sample app, and I am still struggling with the Internal Error issue. – Fran Marzoa Jun 06 '13 at 11:20
  • 1
    Ok, I have noticed that when I export a signed package of the app it works as expected, so it seems like I need to use a different debug key for debugging version of the app... it sounds quite reasonable now. – Fran Marzoa Jun 06 '13 at 13:55
  • 3
    Your hash signature can also change if you use a build distribution service like TestFairy. If suddenly you get "An internal error occurred" with your TestFairy builds, that's likely the issue. See [this post](http://dev.iachieved.it/iachievedit/?p=277) for additional details. – Joe Jun 22 '14 at 18:07
  • It can also happen if you have recently published your games service from the developers console. It takes time for it to take effect. – Ogen Jul 04 '14 at 18:30
  • If you have already set your SHA1 fingerprint (debug or release) in your google developer console and you still having this problem, check if you effectively build with your key, here is the way to set the key in Android Studio: http://stackoverflow.com/a/17992232/2486332 – quent Mar 22 '16 at 20:23
16

I've solved problem by removing .setScopes("PLUS_LOGIN") in the PlusClient.Builder.

marcogramy
  • 586
  • 5
  • 8
  • 1
    I actually had the error go away when I replaced setScopes("PLUS_LOGIN") with setScopes(Scopes.PLUS_LOGIN) for anyone still struggling. – jimbob Jan 20 '14 at 12:20
10

I got this toast message error in my android application:

An internal error occurred

Summary:

Assuming you made a mistake configuring the negotiation between your android app and the Android API server granting you access. Most likely caused by you not adding the correct package name or correct SHA1 fingerprint. I followed these steps to blow out the wrong configuration and do it right.

Steps to fix:

  1. Go to your google api console and login: https://code.google.com/apis/console

  2. Click "API Access" tab.

  3. Click the button: "Create another client ID".

  4. Choose: "Installed Application" radio button.

  5. Choose: "Android" radio button.

  6. Enter the package name of the android app that is displaying the above error. You can find it defined at the top of the PlusSampleActivity.java code file. For me it is com.google.android.gms.samples.plus

  7. Acquire your SHA1 fingerprint value:

    a. Use the command keytool -list -v -keystore /home/el/.android/debug.keystore. Enter password, If you never set it, the default password is 'android'.

    b. The SHA1 fingerprint is shown on screen, copy that.

  8. Paste the above value into the "Signing certificate fingerprint (SHA1):" box.

  9. Click the button: "Create client ID".

  10. Run your android application again, click "Sign in".

Now you are presented with an Activity to "Sign in to Google+ SDK with Google".

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
  • thank you, this is a very good step by step. Note: step 7--> Open your terminal and enter copy/paste this phrase in. Also, modify /home/el/ to point to the home directory. On windows this is something like "C:\Users\[UserName]\.android" – user198923 Aug 12 '14 at 18:19
4

In my case, the solution was to actually set an email address in the Consent Screen. First, I was a bit reluctant to select my personal address and for an strange reason you can save the form without this piece of data with no error. After checking what others have suggested, as soon as I set my email address in that form, it started working.

Alex FJ
  • 81
  • 3
3

I have been searching how to fix this for a day with full of research without luck finally i managed to resolve this issue with the following approach.

Before i begin resolving this (at least how ti worked for me) i have to say that everything on the documentation is correct and you don't have to change any lines of code or so. It looks like more of a bug in the https://cloud.google.com/console cloud console

First ensure you got the correct SHA1 and your project's package name as described in the docs https://developers.google.com/+/quickstart/android

Now this bug as i noticed (at least for me) was that in my cloud console, the project i have created was long ago with the old interface and few months ago i migrated to the new GUI.Once you get the new look on cloud console you will notice that new projects have an auto generated project id like this atlantean-ares-331 while old projects got a long integer value as project id which is not visible. So if your project was created with the old GUI and you have just created new client id for OAuth for that project you will get the Toast "An internal error occurred” while trying to sign in with google.

How to Fix

  1. Go to your cloud console
  2. Make a new project i would suggest a name like oldprojectname-gplus
  3. In APIs section enable Google+ API
  4. Ensure that none of your projects has the same package name on OAuth Client ID with the one you will use now otherwise you will get Error This client ID is globally unique and is already in use.(you will have to delete the old OAuth client id with the same package name you will use now).

  5. Go to Credentials Create New Client ID for OAuth.

Installed application

Android

Enter your project's package name and your SHA1

Done

Geek
  • 8,280
  • 17
  • 73
  • 137
Thano
  • 31
  • 3
2

My solution to the problem was following.

I did everything others recommended and there was no typo regarding the package name and SHA1 key. I also tried removing the key and then adding it again but it didn't help.

What did help is removing the key and creating a new project (at https://code.google.com/apis/console) and then creating the Client ID (with package+sha1) again there. After that (5 secs) everything worked on my Android device.

Zsolt Safrany
  • 13,290
  • 6
  • 50
  • 62
1

This problem is related to the permissions from the api console.

if you are using a permission related with SCOPE_PLUS_LOGIN, in the api console you must create two keys, one for OAuth client id, and other for public api key.

1

In my case the problem was that I changed the package name of the app and didn't update in dev console.

Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
0

For me it was that i was attempting to use my production key when installing it using my debug key. Make sure your using the right SHA1 from the right keystore.

jcaruso
  • 2,364
  • 1
  • 31
  • 64
0

I turned around to the Google IO 2013, and changed the initialization of PlusClient, then it works.

public static final String AUTH_SCOPES[] = {
    Scopes.PLUS_LOGIN,
    "https://www.googleapis.com/auth/userinfo.email",
    "https://www.googleapis.com/auth/developerssite" };

mPlusClient = new PlusClient.Builder(this, this, this)
    .setScopes(AUTH_SCOPES)
    .build();
Tushu
  • 1
0

Thanks Thano for the solution "Now this bug as i noticed (at least for me) was that in my cloud console, the project i have created was long ago with the old interface and few months ago i migrated to the new GUI.Once you get the new look on cloud console you will notice that new projects have an auto generated project id like this atlantean-ares-331 while old projects got a long integer value as project id which is not visible. So if your project was created with the old GUI and you have just created new client id for OAuth for that project you will get the Toast "An internal error occurred” while trying to sign in with google."

0

Recreating the project in the Google Console worked for me after several other attempts:

For any reason my project did not have a project ID (old console/new console?).

As Thano (above) suggested, I created a brand new project, created Client IDs, ... and then in worked. Thanks for the advice!!

user2996950
  • 439
  • 3
  • 8
0

Remember to use the built-in debug keystore for testing. I had everything else working correctly, but I had set my production keystore SHA1 fingerprint in the Credentials in the Developers Console, which caused it not to work.

MikkoP
  • 4,864
  • 16
  • 58
  • 106
0

If your facing this error when you try to run the sample application "or" copy the project which you have created in other machine which was running successfully in that and giving such pop-up error in the other machine where you are trying to run ,you can follow the below method and it will help.

If your are building the app for testing/debug purpose then,

1.Generate the new SHA1 if you copy your project and run it on other machine for the package name and path provided for keystore.

2.Change the ClientId in developers console for new generated SHA1 and run it in the new machine where you have copied the project and trying to run it.

ManishSB
  • 767
  • 9
  • 27
0

Something often overlooked is the package name. I'd like to clarify the step 6 by Eric Leschinski above (can't comment there): the required package is not the package of an activity, rather the package of your app's manifest.

You may retrieve the correct value from the root element of AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ntk.darkmoor"
    android:versionCode="1"
    android:versionName="1.0" >

In this example define "com.ntk.darkmoor" while creating the Client ID

nikos.t
  • 51
  • 3
0

I had the same issue when I used SHA1 for debug.keystore for debuging then exported my application forgetting to generate SHA1 for keystore that I used to export my application.

makunomark
  • 789
  • 6
  • 10
-1

Its working for me when i connect the device and install the apk from Android Studio. But its now working for me when i generate the .apk and install it from dropbox.

Biranchi
  • 16,120
  • 23
  • 124
  • 161
-1

I went through all the answers provided here and others as well. In my case the issue was the SHA-1 as well. The reason I was getting the incorrect SHA-1 was my keytool export cert command.

Previously I was using

C:\Users\mysuername\.android SHA 1 signature keytool -exportcert -alias androiddebugkey -keystore "keystorepath" -list -v

The problem was in the androiddebugkey variable. Here you have to give the name of the key you use for signing the application.

C:\Users\mysuername\.android SHA 1 signature keytool -exportcert -alias mykeyname -keystore "keystorepath" -list -v

Hope this helps someone!

Hadi
  • 520
  • 9
  • 21
-1

To add to this long list of reasons my problem was that i got the debugkey from the jks file rather than the app.

Its always something small.

user237462
  • 387
  • 1
  • 5
  • 24