Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 10 on Android 5+ devices #248

Closed
soorajb opened this issue Jun 20, 2016 · 41 comments
Closed

Error 10 on Android 5+ devices #248

soorajb opened this issue Jun 20, 2016 · 41 comments

Comments

@soorajb
Copy link
Contributor

@soorajb soorajb commented Jun 20, 2016

Hi,

This started happening ever since I created a release version of the apk and it happens only on devices with Android 5+. The plugin works perfectly on debug/release modes on 4.4.
Debug mode works fine on Android 5+, it shows error code 10 in release apk.

Cordova CLI: 6.1.1
Ionic Framework Version: 1.3.1
Ionic CLI Version: 1.7.15
Ionic App Lib Version: 0.7.2
Ubuntu 16.04 LTS
Node Version: v6.1.0

adb logcat doesn't show anything.

Any advice?

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

I have the same error.

Cordova CLI: 6.0.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Framework Version: 1.3.0
Ionic CLI Version: 1.7.15
Ionic App Lib Version: 0.7.2
OS: Windows 8.1
Node Version: v4.4.3
Android : 6.0.1

When Trying to get back to the 4.0.8 version the app crash.

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

I tried everything. I did recheck the client ids for DEBUG and PROD version.
I removed and recreated the plugin with the proper Reverse Client ID - For DEBUG .
I still have the pb.

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

  1. cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --variable REVERSED_CLIENT_ID="com.googleusercontent.apps.********IOS TYPE CLIENT ID **********"

  2. I retested the key generation on Google developer Console.

window.plugins.googleplus.login({
                        'scopes': 'https://www.googleapis.com/auth/contacts.readonly profile email',
                        'offline': true,
                        "webClientId" : *******ANDROID DEBUG CLIENT ID********
                    },
                    function (success) {
                        console.log("window.plugins.googleplus.login", JSON.stringify(success));

                    },
                    function (err) {
                        console.error("window.plugins.googleplus.login",err); // HERE ERROR 10.
                    }

It was working before, I don't know what I did :/

When trying with a released signed APK I encounter the error 12501

@sammugg

This comment has been minimized.

Copy link
Collaborator

@sammugg sammugg commented Jun 21, 2016

@ronyrun
You need to pass in a Web Application type client ID to the login function. Not Android debug.

@soorajb, please double check that you are passing in the correct client ID, too.

@soorajb

This comment has been minimized.

Copy link
Contributor Author

@soorajb soorajb commented Jun 21, 2016

@sammuggPS I am passing an empty object as first argument, won't it work ?

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

@sammuggPS OK I'm on it thank you very much dude.

@sammugg

This comment has been minimized.

Copy link
Collaborator

@sammugg sammugg commented Jun 21, 2016

@soorajb Oh It should work with an empty object. Hmm. Can you get the logcat output?

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

It's working on my side ! thank so much @sammuggPS
I didn't this was working like that now.

I'm a bit lost now, because I used to deal with a oauthToken in order to get user information from my backend side. (Node + passport-google-oauth) :/
Do you know now how to manage it on Backend side ?

@sammugg

This comment has been minimized.

Copy link
Collaborator

@sammugg sammugg commented Jun 21, 2016

@ronyrun the oauthToken is now called serverAuthCode. It's the same value, but the naming now matches up with what google calls it.

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

@sammuggPS oh ok then I'll use that.
thank you I'm gonna try that.

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

OK I think I have to rework the backend side, because I used to call an access_token and now I got an Unauthorized error.

I'm on the good way :)
thanks.

@soorajb

This comment has been minimized.

Copy link
Contributor Author

@soorajb soorajb commented Jun 21, 2016

oh, my bad, just figured out that this was because the SHA1 fingerprint of the release key was generated without the "aliasname". I entered the correct SHA1 now and it works perfectly.
Google documentation doesn't mention to add "-alias". Seems to be affecting only Android 5+ devices

@soorajb soorajb closed this Jun 21, 2016
@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

@soorajb how did you generate the webClientId (Web Application Client id) ? is it a proper web application id type ?
I don't understand because the SHA1 fingerprint works only with Android type Client Id

@sammugg

This comment has been minimized.

Copy link
Collaborator

@sammugg sammugg commented Jun 21, 2016

@soorajb Ohhhh good catch! Because you figured that out, could do us a favor? Would you be able to write up a short blurb about generating the release key so we can add a note to our documentation? Thanks!

@ronyrun, he wasn't passing any options into the plugin methods, so he didn't need to get the web client id. The SHA1 fingerprint is how Google identifies what application is hitting its APIs. On iOS is uses the name space (i.e. com.example.namespace). Make sense?

@soorajb

This comment has been minimized.

Copy link
Contributor Author

@soorajb soorajb commented Jun 21, 2016

@ronyrun I just want to access users email and basic profile, so nothing is needed. First argument can be an empty object for android.
But just create a Oauth 2.0 client id with correct SHA1 ( google docs doesn't mention to add -alias) and package name.

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

OK @soorajb @sammuggPS thank you.

I'm a bit lost - I used to do that before :

  1. Ionic mobile app - Google + auth Press
  2. Get oauthToken from the client
  3. On the Backend : use an Oauth2 Web Application Client + Client Secret
  4. Connect on Google and get the user Profil & mail with the oauthToken

Doing the same with the serverAuthCode as "access_token" gives an Unauthorized error.

@soorajb

This comment has been minimized.

Copy link
Contributor Author

@soorajb soorajb commented Jun 21, 2016

@sammuggPS Done. Thanks!.

@sammugg

This comment has been minimized.

Copy link
Collaborator

@sammugg sammugg commented Jun 21, 2016

@ronyrun, that's because the serverAuthCode is not an access_token. It can be exchanged for an access and refresh token.

@ronyrun

This comment has been minimized.

Copy link

@ronyrun ronyrun commented Jun 21, 2016

Thank you,

I'll try to get the access_token from the Cordova application and not from the backend.

@risleylima

This comment has been minimized.

Copy link
Contributor

@risleylima risleylima commented Aug 18, 2016

@ronyrun, on my application, I generated and registered the 2 certificate fingerprint for google OAuth, on "Credentials" menu, in Google Developers Console

1 for debug.keystore, which on MAC (Unix) is located in ~/.android/debug.keystore, with this command:
keytool -exportcert -list -v \ -alias androiddebugkey -keystore ~/.android/debug.keystore
better explained here

2 for release.keystore with the same command, but changed the alias and the path to fit with my another keystore parameters.

For android application, you don't have to create the "Web Application Id".

When calling the function to login, you have to pass an empty object to the function, otherwise you will fall in the 12501 error.

If you did all of this configuration, and still getting the error 10, and you created the credentials with the correct certificate fingerprints, it's because your bundle application id, on your config.xml, don't fit with the package name provided when you created the credentials on google developers console.

Please verify if your "id" attribute on widget tag on your config xml match with the package name on your credential configuration.

Pay attention that you need to have 2 credentials configured on google developers console, 1 for debug and 1 for production (release).

When installing the plugin, put the release certificate fingerpring reversed client id on the parameters.

--variable REVERSED_CLIENT_ID="com.googleusercontent.apps.********ANDROID RELEASE CLIENT ID**********"

If you want the iOS application, you have to install the plugin using the android release client id and simply add another credential for iOS application, paying attention to insert the package ID that is equal to your config.xml too.

Hope it helped.

@sammugg

This comment has been minimized.

Copy link
Collaborator

@sammugg sammugg commented Aug 18, 2016

@risleylima,
The REVERSED_CLIENT_ID is not used for the Android plugin at all. It is only applied for the iOS side.

If you are developing only for Android, you do not need to include the REVERSED_CLIENT_ID.

@risleylima

This comment has been minimized.

Copy link
Contributor

@risleylima risleylima commented Aug 18, 2016

@sammuggPS,
Thanks for the update, it's absolutely correct!

I only put that information, cause I thought that @ronyrun is trying to build a hybrid application, on both platforms.

In my case, when I build my app, I inserted the Android release client ID on the 'REVERSED_CLIENT_ID', and the plugin worked on all the platforms, Android and iOS, and for debug and release versions.

@cfontana0

This comment has been minimized.

Copy link

@cfontana0 cfontana0 commented Oct 13, 2016

Hey guys!!
I configured the plugin based on the README.md file and It worked great on iOS, and with Android <5.
However, it doesn't work with Android >= 5.
These are the steps that I did for that:

  • Generated a new keystore using this line
    keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
  • This that keystore, I got the SHA1 and added the Google Service in this site
    I'm sure that I configure the app name and the package name correctly based on the Ionic project.
    Besides, I set the obtained SHA1.
  • That generated the OAuth 2.0 client IDs on this site
  • Installed the plugin using: cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=com.googleusercontent.apps....
    The REVERSED_CLIENT_ID is the one that I got for the iOS.
    This one is only used on iOS, right? So I guess that it is not the problem.
  • Ran the project and the plugin worked fine on iOS and Android<4... but not for Android>4.

I'm not sure if I generated correctly the keystore...maybe I have to use another one related to the project.
Besides, should I generate two fingerprints? that is not clear for me.

I always get Error: 10 when I run the app in Android >= 5.ANNB6VCXZ
Any idea how to solve it?
Thanks!

@jobuli

This comment has been minimized.

Copy link

@jobuli jobuli commented Oct 16, 2016

My steps also same as yours and facing same issue. Working in android < 5 but bot in android >= 5. Did you solve this?

@jobuli

This comment has been minimized.

Copy link

@jobuli jobuli commented Oct 16, 2016

Ok. I got it resolved. But an entirely different reason. I was creating build using CLI on gitbash. This caused the error. I did same steps using windows cmd.exe and everything worked fine. Both debug and production builds are working fine.

@cfontana0

This comment has been minimized.

Copy link

@cfontana0 cfontana0 commented Oct 16, 2016

Hey @jobuli which keystore did you use? I'm not sure about it.
I created a new one, and configured it on the G+ server, and I got the Error 10 issue.

I used the ~/.android/debug.keystore one, and I had the Error 8 issue.

So, I think that it is related to it.

I don't know how to relate the generated keystore with the app.

Any idea?

@jobuli

This comment has been minimized.

Copy link

@jobuli jobuli commented Oct 16, 2016

@cfontana0
I used my prod clientID and sha1 key. I did not check with debug.

I did the following.
cordova plugin rm cordova-plugin-googleplus --save
cordova platform rm android
cordova platform add android
cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --save --variable REVERSED_CLIENT_ID=
cordova prepare
ionic run android (I used physical device)

Then i created my release build. Here is how I called login with values.

        window.plugins.googleplus.login({
            'scopes' : 'profile email',
            'offline' : true
        }, function(obj) {

for some google accounts obj.givenName is null and i used displayName. My business is ok with it.

      if (!obj.givenName && (obj.displayName != obj.email)) {
                    var names = obj.displayName.split(" ");
                    obj.givenName = names[0];
                    obj.familyName = names[1];
                }
@jobuli

This comment has been minimized.

Copy link

@jobuli jobuli commented Oct 16, 2016

@cfontana0 One more to note :
Adding SHA1 key in https://developers.google.com/mobile/add will automatically add credentials in API Manager console.
I added one more credential manually with same SHA1 key (wont throw duplicate error) and did not use this client id anywhere.

@cfontana0

This comment has been minimized.

Copy link

@cfontana0 cfontana0 commented Oct 16, 2016

Hey @jobuli thanks!

Why did you add another SHA1 key?

Did you generated the SHA1 from a keystore generated by you or did you used another one? which one?

I used this line keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

Generated the keystore, got the SHA1 based on that, and added it to the developer.google console.

Besides, which is the client id? it is the app ID that we use on the store? for example com.xxx.xxx

@jobuli

This comment has been minimized.

Copy link

@jobuli jobuli commented Oct 16, 2016

@cfontana0 I generated my own keystore and pulled SHA1 key.
Most people create credentials manually. I think we both used method to create automatically, just an instinct i added manually and tried. I deleted manually created credential and got error 10. I added back it worked.
Now i have both automatically added and manually added. I dont want to delete the credential created automatically regardless its client id is used by the app or not. Coz, It is in my config.xml and the build went to prod.

you can see the client id below available in API manager --> credentials page. its the same as REVERSED_CLIENT_ID.

Name Creation date Type Client ID
somename Oct 16, 2016 Android xxxxxxx-xxxxxxxxxx.apps.googleusercontent.com

@s4dman

This comment has been minimized.

Copy link

@s4dman s4dman commented Oct 20, 2016

I was having the same issue. Everything was working fine below Android 5.0.

But from android 5.0> I was getting Error 10 all the time when I was trying to run debug apk.

But the moment I tried with my released apk everything's working perfect.

** I think the issue is with SHA-1. **

Your app must be signed with the same SHA-1 as the Google Sign In Project , which is located in API Console > Credentials

Use only debug keystore SHA-1 on both items or use only production keystore SHA-1.
Don't Mixup !

@jobuli

This comment has been minimized.

Copy link

@jobuli jobuli commented Oct 28, 2016

@cfontana0 you got the issue fixed?
if your debug build is still having this issue, it may be using the keystore from your eclipse. Create credential using SHA1 Key from your eclipse and check.

android sha1-key

@cfontana0

This comment has been minimized.

Copy link

@cfontana0 cfontana0 commented Nov 10, 2016

Hey guys! I used the SHA1 based on the same keystore used to sign the APK.
After that, I signed the APK file with it and it works! :)

@cfontana0

This comment has been minimized.

Copy link

@cfontana0 cfontana0 commented Nov 16, 2016

Hey guys! I'm back :(

I have the following issue:

  • If I run the "ionic build android --release" command, and sign the APK file using the keystore that I used to configure the login in the Google Develop Console. Everything works fine.
  • If I do the same, with the same code, and the same keystore, but in another computer, I have the Error 10 issue.... I don't understand why.

Any idea?

@s4dman

This comment has been minimized.

Copy link

@s4dman s4dman commented Nov 17, 2016

@cfontana0 Make sure your keystore is the release keystore not the debugging on. Because here your apk is the release apk.

@MaddoScientisto

This comment has been minimized.

Copy link

@MaddoScientisto MaddoScientisto commented Jun 18, 2017

Hey guys I just solved this, even if it's an old question it might still help people who have issues getting this to work and find this through google:

Solution is really simple: just get your own debug keystore (there should be already one at C:\Users\yourname\.android\debug.keystore) and place it in the root directory of your application.
Then go in platforms/android and create a file named "debug-signing.properties" (you can also make a release-signing.properties file, this is how I found this solution) and paste in the following:

target=android-25
android.library.reference.1=CordovaLib
keyPassword=android
storePassword=android
keyAlias=androiddebugkey
storeFile=../../debug.keystore

that's it, now every time your app is compiled it should use that one keystore, no more weird hashes for who knows where.

Why this happens? Because the compiler pulls out some keystore from who knows where and it surely is not the one in your user folder, that's what kept confusing me

@sertykos

This comment has been minimized.

Copy link

@sertykos sertykos commented Jun 19, 2017

@MaddoScientisto Thank you very much for this. I am going to try it ASAP because I´ve been trying to solve this for the past two days with no luck. ;)

@dedd1993

This comment has been minimized.

Copy link

@dedd1993 dedd1993 commented Jun 20, 2017

My android-debug.apk was working fine, my problem was with the release-android.apk when y was signing it for playstore.

Solution:

  1. Open terminal on my release-key.keystore path and run 'keytool -list -v -keystore <keystore_name> -alias <alias_name>' .
    2.Go to your project's credentials page (https://console.developers.google.com/apis/credentials) and replace the SHA1 to your keystore's release SHA1.
@aghiecool

This comment has been minimized.

Copy link

@aghiecool aghiecool commented Aug 27, 2017

I have the same problem. And here is the solution that worked for me.
I was using ionic, so i create build.json file contains these:

{
    "android": {
        "debug": {
            "keystore": "my.keystore",
            "storePassword": "mypassword",
            "alias": "my_app",
            "password" : "mypassword",
            "keystoreType": ""
        },
        "release": {
            "keystore": "my.keystore",
            "storePassword": "mypassword",
            "alias": "my_app",
            "password" : "mypassword",
            "keystoreType": ""
        }
    }
}

My Credential is already created on Google Dev Console.
I was using "OAuth Client ID -> Android"

So every time i wanna run my app I just type "ionic cordova run android --buildConfig=build.json"
It will force cordova to sign using keystore I provided in build.json file.
I also use the same keystore file for debug and release with no problem.
Hope it helps

@lreb

This comment has been minimized.

Copy link

@lreb lreb commented Dec 1, 2017

thanks @sammuggPS I was using android client id instead web application

@xProgrammer-007

This comment has been minimized.

Copy link

@xProgrammer-007 xProgrammer-007 commented Apr 3, 2018

no luck ! tried signing it , used web client id , still the issue persists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.