EddyVerbruggen / cordova-plugin-googleplus

:heavy_plus_sign: Cordova plugin to login with Google Sign-In on iOS and Android
566 stars 625 forks source link

Working on Samsung TAB3, but getting error "10" on Gallaxy S5 #240

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi,

I've got this working fine on my Samsung Gallaxy Tab, but using the exact same APK (so same SHA1 key etc) on my Samsung Gallaxy S5 produces an error code "10". Which according to Google's status codes means developer error.

I don't understand what could be causing the problem on the S5 but working on the TAB3.

Please can you perhaps shed some light on this form me?

ghost commented 8 years ago

I'm still struggling with this and would appreciate your feedback @EddyVerbruggen

By the way I get the same error ("10") using your demo index.html

ghost commented 8 years ago

Ok, so I just removed the plugin (from git) and reinstalled the one on npm... and that one works fine!

Except that it says it's using a depreciated version of the API.

Please can you assist.

Thanks.

sammugg commented 8 years ago

The version on git right now was updated to remove the usage of deprecated API versions.

What versions of Android are each device running?

ghost commented 8 years ago

Yes I'm aware that the git version is using the later API, however it gives error 10 on Android 5.0. It works on Android 4.2.2 (the tablet I tested it on) and version 4.4 the other GS4 I test it on.

The plugin on npm (which uses the depreciated API) seems to work on both.

sammugg commented 8 years ago

Can you tell me more about your project?

What versions of Cordova/PhoneGap/whatever are you using? How are you building the project? What SHA1 did you use for the dev console set up? How are you calling the plugin? Are you waiting for device ready?

ghost commented 8 years ago

Using Intel XDK, 3357 (latest)

Cordova 5.4.1

Building in the XDK cloud

SHA1 is created using keytool on the APK (as mentioned it's not a SHA1 issue as it works using the depreciated API, also if I do put in the wrong package name or SHA1 I get different error - invalid token or invalid_audience).

I am calling the plugin long after the device is ready as it's being called on a button click. Again this works find using the NPM version - just not the GIT version.

$scope.gLogin = function() {

    $ionicLoading.show({templateUrl: "loading.html"});

    window.plugins.googleplus.login(
        {'scopes':'profile email',
        'webApiKey':'xxx.apps.googleusercontent.com',
        'return':true
        },
        function (data) {
            manualLoginResponse('google', data);
        },
        function (error) {
            manualLoginFailed('google', error);
        }
    );

};

(bear in mind it says "webApiKey" because its the NPM version.)

sammugg commented 8 years ago

Okay, I think your issue might be that you're building in the cloud. Building in the cloud means your building on a different system than your own so the SHA1 that you created locally is not the same as the one that's being used in the cloud.

My recommendation would be to try building it locally and see what happens.

ghost commented 8 years ago

No I generate the SHA1 after I receive the compiled APK, trust me its not a SHA1 problem.

ghost commented 8 years ago

I've also just tested it now for you by building the project locally in cordova directly... get my SHA1 update credentials on google, same error.

ghost commented 8 years ago

The problem is 100% not to do with the SHA1 or package name. I have confirmed this already by virtue of the fact that is WORKS on my tablet running older version of Android and play services. If the SHA1 or package name were wrong, it would not work on any device.

ghost commented 8 years ago

@sammuggPS have you managed to make any headway on this? Really love the plugin and though I do have it working with the NPM version, I'm obviously not wanting to publish it while it's using a depreciated API.

Thanks.

sammugg commented 8 years ago

I'm at a loss. I don't know much about Intel XDK, so I'm not sure if there's anything specific to that that could be causing issues.

Is your Android SDK up to date? Do you have Google Play Services installed?

ghost commented 8 years ago

I think perhaps you're missing the problem here....

Even if I build a project using nothing other than cordova - I get error 10 using the GIT version, works with NPM version.

So it's got nothing to do with Intel XDK.

sammugg commented 8 years ago

I'm not missing the problem. I'm just trying to narrow down the cause. My previous questions are very important in trying to figure that out. I'm trying to make sure that you have all the prerequisites as detailed here: https://developers.google.com/identity/sign-in/android/start-integrating

ghost commented 8 years ago

Ok, I'm not sure how else to explain this to you.

  1. All requirements for Google's API is met, the correct SHA1 key and package names are being used. a. This is evident by the fact that it works using the NPM version of the plugin. b. If (for testing purposes) I deliberately use the wrong SHA1/package name I get errors from the API such as invalid token or invalid_audience
  2. Using either Intel XDK (built in the cloud) OR building locally on my own system using cordova only, the GIT version provides an error "10" on newer android devices (works still on older devices). a. However if I use the NPM version in either Intel XDK or cordova locally, it works on all devices. b. The caveat is that I receive the warning at build time about the plugin making use of depreciated APIs.

To summarise. The problem is not to do with SHA1/google dev console settings and it is not to do with the build environment. It thus appears that somewhere in the code of the later version (GIT) it is doing something that newer versions of Android simply does not like. And the error "DEVELOPER_ERROR" is provided, with no further information as to the cause of said error.

I hope this provides more insight from my side.

You can test this yourself though?

sammugg commented 8 years ago

1) Please check that Google Play services is up to date. Just to be sure. Just because the NPM version is working doesn't mean your SDK versions are correct for the latest version of the Sign In platform.

2) Can you provide a logcat output of what's happening leading up to the error code? Preferably scoped to just the application.

ghost commented 8 years ago
  1. SDK on both Intel XDK and on my system are the latest versions.
  2. There are no logs, it runs smooth until the reply comes from your plugin as an error and the only msg is "10".
sammugg commented 8 years ago

I meant device logs. Remember it's running native code, so there are separate logs that don't show up in the Chrome debugger. Here are some steps to get the output:

  1. Plug in your phone (with the app not running)
  2. open a terminal on your computer
  3. run adb logcat (You should see a bunch of initial output)
  4. Hit enter a few times to leave some space
  5. Start your app and go through the login process up til your error 10
  6. When you see the error, copy all of the output from the space that you created up to the error.
  7. Save that to a text file and send that to me (try https://linx.li/ if you can't think of an easier way)
ghost commented 8 years ago

Here you go...

shell@klte:/ $ logcat | grep 14992 logcat | grep 14992 E/Zygote (14992): MountEmulatedStorage() E/Zygote (14992): v2 I/libpersona(14992): KNOX_SDCARD checking this for 10359 I/libpersona(14992): KNOX_SDCARD not a persona I/ActivityManager( 905): Start proc za.co.trainingtime.app for activity za.co.trainingtime.app/.MainActivity: pid=14992 uid=10359 gids={50359, 9997, 3003} abi=armeabi-v7a I/SELinux (14992): Function: selinux_compare_spd_ram, SPD-policy is existed. and_ver=SEPF_SM-G900F_5.0-1 ver=51 I/SELinux (14992): Function: selinux_compare_spd_ram , priority [1] , priority version is VE=SEPF_SM-G900F_5.0-1_0051 E/SELinux (14992): [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL I/art (14992): Late-enabling -Xcheck:jni D/TimaKeyStoreProvider(14992): TimaSignature is unavailable D/ActivityThread(14992): Added TimaKeyStore provider D/ResourcesManager(14992): creating new AssetManager and set to /data/app/za.co.trainingtime.app-1/base.apk I/FirebaseInitProvider(14992): FirebaseApp initialization unsuccessful I/WebViewFactory(14992): Loading com.google.android.webview version 50.0.2661.86 (code 266108600) D/ResourcesManager(14992): creating new AssetManager and set to /data/app/com.google.android.webview-1/base.apk I/cr_LibraryLoader(14992): Time to load native libraries: 6 ms (timestamps 5344-5350) I/cr_LibraryLoader(14992): Expected native library version number "50.0.2661.86", actual native library version number "50.0.2661.86" V/WebViewChromiumFactoryProvider(14992): Binding Chromium to main looper Looper (main, tid 1) {359eb708} I/cr_LibraryLoader(14992): Expected native library version number "50.0.2661.86", actual native library version number "50.0.2661.86" I/chromium(14992): [INFO:library_loader_hooks.cc(143)] Chromium logging enabled: level = 0, default verbosity = 0 I/cr_BrowserStartup(14992): Initializing chromium process, singleProcess=true E/ApkAssets(14992): Error while loading asset assets/natives_blob_64.bin: java.io.FileNotFoundException: assets/natives_blob_64.bin E/ApkAssets(14992): Error while loading asset assets/snapshot_blob_64.bin: java.io.FileNotFoundException: assets/snapshot_blob_64.bin I/Adreno-EGL(14992): : EGL 1.4 QUALCOMM build: () I/Adreno-EGL(14992): OpenGL ES Shader Compiler Version: E031.25.01.03 I/Adreno-EGL(14992): Build Date: 03/03/15 Tue I/Adreno-EGL(14992): Local Branch: LA.BF.1.1_RB1_20150108_025_1077123_1158499 I/Adreno-EGL(14992): Remote Branch: I/Adreno-EGL(14992): Local Patches: I/Adreno-EGL(14992): Reconstruct Branch: W/cr_media(14992): Requires BLUETOOTH permission I/art (14992): Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.WebViewContentsClientAdapter$WebResourceErrorImpl> I/art (14992): Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.WebViewContentsClientAdapter$WebResourceErrorImpl> I/art (14992): Rejecting re-init on previously-failed class java.lang.Class I/art (14992): Rejecting re-init on previously-failed class java.lang.Class D/cr_Ime (14992): [InputMethodManagerWrapper.java:30] Constructor W/cr_AwContents(14992): onDetachedFromWindow called when already detached. Ignoring D/cr_Ime (14992): [InputMethodManagerWrapper.java:59] isActive: false D/SystemWebViewEngine(14992): CordovaWebView is running on device made by: samsung I/cr_Ime (14992): ImeThread is not enabled. D/Activity(14992): performCreate Call secproduct feature valuefalse D/Activity(14992): performCreate Call debug elastic valuetrue D/OpenGLRenderer(14992): Render dirty regions requested: true I/OpenGLRenderer(14992): Initialized EGL, version 1.4 I/OpenGLRenderer(14992): HWUI protection enabled for context , &this =0xa0347060 ,&mEglDisplay = 1 , &mEglConfig = 8 D/OpenGLRenderer(14992): Enabling debug mode 0 E/libEGL (14992): validate_display:255 error 3008 (EGL_BAD_DISPLAY) E/Adreno-ES20(14992): : Invalid texture format! Returning error! E/Adreno-ES20(14992): : Framebuffer color attachment incomplete. Returning GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT! W/cr_BindingManager(14992): Cannot call determinedVisibility() - never saw a connection for the pid: 14992 D/cr_Ime (14992): [InputMethodManagerWrapper.java:59] isActive: true D/cr_Ime (14992): [InputMethodManagerWrapper.java:68] hideSoftInputFromWindow I/Timeline(14992): Timeline: Activity_idle id: android.os.BinderProxy@1bff648b time:256235751 D/JsMessageQueue(14992): Set native->JS mode to OnlineEventsBridgeMode I/chromium(14992): [INFO:CONSOLE(47)] "Received Event: deviceready", source: file:///android_asset/www/js/index.js (47) E/Adreno-ES20(14992): : Invalid texture format! Returning error! E/Adreno-ES20(14992): : Framebuffer color attachment incomplete. Returning GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT! I/InputDispatcher( 905): Delivering touch to (14992): action: 0x0, toolType: 1 D/ViewRootImpl(14992): ViewPostImeInputStage ACTION_DOWN I/InputDispatcher( 905): Delivering touch to (14992): action: 0x1, toolType: 1 I/GooglePlugin(14992): Building Google options I/GooglePlugin(14992): Building GoogleApiClient I/GooglePlugin(14992): GoogleApiClient built I/GooglePlugin(14992): Determining command to execute I/GooglePlugin(14992): Trying to Log in! I/Timeline(14992): Timeline: Activity_launch_request id:za.co.trainingtime.app time:256273792 W/PluginManager(14992): THREAD WARNING: exec() call to GooglePlus.login blocked the main thread for 41ms. Plugin should use CordovaInterface.getThreadPool(). D/Activity(14992): performCreate Call secproduct feature valuefalse D/Activity(14992): performCreate Call debug elastic valuetrue D/cr_Ime (14992): [InputMethodManagerWrapper.java:59] isActive: true D/cr_Ime (14992): [InputMethodManagerWrapper.java:68] hideSoftInputFromWindow I/Timeline(14992): Timeline: Activity_idle id: android.os.BinderProxy@232290d6 time:256273894 D/CordovaInterfaceImpl(14992): Sending activity result to plugin I/GooglePlugin(14992): In onActivityResult I/GooglePlugin(14992): One of our activities finished up I/GooglePlugin(14992): Handling SignIn Result I/GooglePlugin(14992): Wasn't signed in I/Timeline(14992): Timeline: Activity_idle id: android.os.BinderProxy@1bff648b time:256278812

sammugg commented 8 years ago

Can you do it again without the grep command? Just want to make sure there isn't an error call that's getting filtered out.

ghost commented 8 years ago

The logcat is completely polluted by many apps on the device, it would be next to impossible to siphon out this apps logs if I did that?

sammugg commented 8 years ago

I'll try to narrow it down. I'm just looking for anything out of the ordinary, specifically errors or exceptions.

ghost commented 8 years ago

x.txt

Here you go, it seems it might have something to do with: E/Parcel ( 905): Class not found when unmarshalling: com.google.android.gms.auth.api.signin.internal.SignInConfiguration

E/Parcel ( 905): java.lang.ClassNotFoundException: com.google.android.gms.auth.api.signin.internal.SignInConfiguration

E/Parcel ( 905): at java.lang.Class.classForName(Native Method)

E/Parcel ( 905): at java.lang.Class.forName(Class.java:308)

E/Parcel ( 905): at java.lang.Class.forName(Class.java:272)

E/Parcel ( 905): at android.os.Parcel.readParcelableCreator(Parcel.java:2275)

E/Parcel ( 905): at android.os.Parcel.readParcelable(Parcel.java:2239)

E/Parcel ( 905): at android.os.Parcel.readValue(Parcel.java:2146)

E/Parcel ( 905): at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)

E/Parcel ( 905): at android.os.BaseBundle.unparcel(BaseBundle.java:221)

E/Parcel ( 905): at android.os.BaseBundle.getString(BaseBundle.java:918)

E/Parcel ( 905): at android.content.Intent.getStringExtra(Intent.java:5378)

E/Parcel ( 905): at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1759)

E/Parcel ( 905): at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1305)

E/Parcel ( 905): at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:4616)

E/Parcel ( 905): at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:4454)

E/Parcel ( 905): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:142)

E/Parcel ( 905): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3021)

E/Parcel ( 905): at android.os.Binder.execTransact(Binder.java:446)

E/Parcel ( 905): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.signin.internal.SignInConfiguration" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

E/Parcel ( 905): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

E/Parcel ( 905): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

E/Parcel ( 905): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)

E/Parcel ( 905): ... 17 more

sammugg commented 8 years ago

Yeah "Class not found" could definitely be an issue. So for some reason, your phone doesn't have, or isn't getting, the up to date Google APIs, but your tablet is.

sammugg commented 8 years ago

The following sequence occurs every time error '10' and the SignInConfiguration exception comes up:

I/GooglePlugin(32377): Building Google options
I/GooglePlugin(32377): Building GoogleApiClient
I/GMPM    (32485): App measurement is starting up
I/GooglePlugin(32377): GoogleApiClient built
I/GooglePlugin(32377): Determining command to execute
I/GooglePlugin(32377): Trying to Log in!
I/Timeline(32377): Timeline: Activity_launch_request id:za.co.trainingtime.app time:258885721
E/PersonaManagerService(  905): inState():  stateMachine is null !!
E/GMPM    (32485): getGoogleAppId failed with status: 10
E/GMPM    (32485): Uploading is not possible. App measurement disabled
E/Parcel  (  905): Class not found when unmarshalling: com.google.android.gms.auth.api.signin.internal.SignInConfiguration
E/Parcel  (  905): java.lang.ClassNotFoundException: com.google.android.gms.auth.api.signin.internal.SignInConfiguration

Quick search of 'getGoogleAppId failed with status: 10' brought me to the following Q/A: http://stackoverflow.com/questions/33531689/error-getgoogleappid-failed-with-status-10-android-kitkat-gcm-and-google-driv

Hope that can help you out! I don't know what other Google things you're using.

ghost commented 8 years ago

Nope, it does not help unfortunately. They're on about the Google credentials, but as I've said numerous times, this works when I use the NPM version with the same method of obtaining credentials and setting in the dev console.

It's got more to do with the fact that the new version on GIT is doing things differently and Android Lollipop doesn't like it.

ghost commented 8 years ago

Since the NPM version seems to work, what would the repercussions be if I just used that? Would my app eventually stop working?

ghost commented 8 years ago

I think I have managed to get it to work now with the GIT version....

However, with the NPM version I was returned values such as givenName and familyName, yet on the GIT version these are not returned... is there a reason for this?

Looking at the GIT java I see you've not put it in there, whereas in the NPM java its there:

GIT: try { Log.i(TAG, "trying to get account information");

            result.put("email", acct.getEmail());

            //only gets included if requested (See Line 164).
            result.put("idToken", acct.getIdToken());

            //only gets included if requested (See Line 166).
            result.put("serverAuthCode", acct.getServerAuthCode());

            result.put("userId", acct.getId());
            result.put("displayName", acct.getDisplayName());
            result.put("imageUrl", acct.getPhotoUrl());

            this.savedCallbackContext.success(result);
        }

NPM: try { result.put("email", email); // in case there was no internet connection, this may be null if (user != null) { result.put("userId", user.getId()); result.put("displayName", user.getDisplayName()); result.put("gender", getGender(user.getGender())); if (user.getImage() != null) { result.put("imageUrl", user.getImage().getUrl()); } if (user.getName() != null) { result.put("givenName", user.getName().getGivenName()); result.put("middleName", user.getName().getMiddleName()); result.put("familyName", user.getName().getFamilyName()); if (user.hasAgeRange()) { if (user.getAgeRange().hasMin()) { result.put("ageRangeMin", user.getAgeRange().getMin()); } if (user.getAgeRange().hasMax()) { result.put("ageRangeMax", user.getAgeRange().getMax()); } } if (user.hasBirthday()) { result.put("birthday", user.getBirthday()); } } } resolveToken(email, result); }

ghost commented 8 years ago

Nevermind, I'll just make a $http call to https://www.googleapis.com/oauth2/v3/tokeninfo?id_token= with the token received from the plugin so I can get the user details that way. Thanks.

sammugg commented 8 years ago

What did you change to get the Git version to work?

And yes there is an explanation for less info coming back:

When I refactored the plugin, one of my goals was to narrow the scope of its functionality. Part of narrowing that scope meant more clearly defining the purpose of the plugin: to identify and authenticate a user using Google. The default information coming back from the Git version is focused on those aspects: identity from name, email, and picture + authentication through a valid idToken and/or a valid serverAuthCode being returned.

In the README, I stated that any further information, i.e. birthday, age range, etc. is specific to whatever application this is being used in and beyond the scope of this plugin's purposes.. Therefore, the retrieval of any additional information is on the developer (i.e. You) to implement into their application.

ghost commented 8 years ago

It appears you do actually need the json file, because once I added that back, it started to work. shrug.

Understood regarding the removal of familyName etc, I've just made use of separate calls to the Web API using the accessToken in order to get these now.

Thanks for all your assistance with my issue!

sammugg commented 8 years ago

Ohhhh that's weird. Where did you add the json file?

ghost commented 8 years ago

In the project root. I originally did not have one because your instructions say you no longer need one for Android. But after adding it and making sure it had the correct details in it, the app magically began working shrug

rajitgarg2 commented 8 years ago

hi @lemondesigns, can you please inform , how you have resolve this issue, I am not understand , what you mean by saying that you have add the json file in the project root, (which json file) please inform to me in some detail, as I am very new to all this, requested you to please inform?

rajitgarg2 commented 8 years ago

hurrayyy, I found my mistake that i am doing, I am using different id in config.xml and using different name, when creating configuration file for IOS/Android. it should be same

This official docs are really awesome https://github.com/EddyVerbruggen/cordova-plugin-googleplus

But I am able to do this by using git repo only, when i am using npm module for adding plugin getting deprecated API error.

Thanks a lot anyway, This article also helps me a lot

sammugg commented 8 years ago

@rajitgarg2 Thanks for referencing the official docs! We're continually trying to improve them, so let us know if there's any additions we can make.

mitul69 commented 8 years ago

Hello Please follow the following steps and download the google-service.json and put it in www directory it's working fine for me.

Link for the steps. https://developers.google.com/identity/sign-in/android/start?configured=true

I have tried lot's of option but then success using above steps.