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

package com.google.android.gms.auth does not exist #252

Open williantenfen opened 8 years ago

williantenfen commented 8 years ago

Any idea on this:

/ionic-test/platforms/android/src/nl/xservices/plugins/GooglePlus.java:11: error: package com.google.android.gms.auth does not exist import com.google.android.gms.auth.GoogleAuthException;

/ionic-test/platforms/android/src/nl/xservices/plugins/GooglePlus.java:12: error: package com.google.android.gms.auth does not exist import com.google.android.gms.auth.GoogleAuthUtil;

/ionic-test/platforms/android/src/nl/xservices/plugins/GooglePlus.java:13: error: package com.google.android.gms.auth does not exist import com.google.android.gms.auth.UserRecoverableAuthException;

Ionic info: Cordova CLI: 6.2.0 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.10 Ionic CLI Version: 2.0.0-beta.32 Ionic App Lib Version: 2.0.0-beta.18 OS: Distributor ID: LinuxMint Description: Linux Mint 17.3 Rosa Node Version: v4.4.1

config.xml :

<plugin name="cordova-plugin-googleplus" spec="4.0.8">
    <variable name="REVERSED_CLIENT_ID" value="lalallalala.Xxxx.ntent.com"/>
  </plugin>

Thanks!

ghost commented 8 years ago

I have the same issue. Try to add with GitJub instead npm:

cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --save --variable REVERSED_CLIENT_ID=myreversedclientid

alexissusset commented 8 years ago

+1 on this issue

Adding cordova-plugin-googleplus to config.xml works on ionic1-ios but not on ionic1-android

igor-slotin commented 8 years ago

Got same issue! Looks like google released new com.google.android.gms I try use previous version. Change in plugin.xml

<framework` src="com.google.android.gms:play-services-plus:+" />
<framework src="com.google.android.gms:play-services-identity:+" />

to

 <framework src="com.google.android.gms:play-services-plus:9.0.2" />
 <framework src="com.google.android.gms:play-services-identity:9.0.2" />

it works for me

spradnyesh commented 8 years ago

install "google repository" from android SDK as mentioned in http://stackoverflow.com/questions/17155475/could-not-find-com-google-android-gmsplay-services3-1-59-3-2-25-4-0-30-4-1-32/17157227#17157227

GwenWing commented 8 years ago

Still fails on Android with GIT plugin (4.0.9)

I have "google repository" installed in android SDK

have switched to: `

` But on Android, I still don't get the expected oauthToken from google-plus auth.

On iOS it's working.

Any help?

andres-torres-marroquin commented 8 years ago

I happened to me too, I fixed it with

 <framework src="com.google.android.gms:play-services-plus:9.0.2" />
 <framework src="com.google.android.gms:play-services-identity:9.0.2" />

But since I use phonegap-plugin-push, additionally I had to change plugin.xml in phonegap-plugin-push from:

<framework src="com.google.android.gms:play-services-gcm:+" /> to <framework src="com.google.android.gms:play-services-gcm:9.0.2" />

If you have more libraries that depend on com.google.android.gms you might have to change them too, ot avoid com.android.dex.DexException: Multiple dex files define

GwenWing commented 8 years ago

Still no luck using Googleplus plugin "4.0.9" running on Android.

amiriltd commented 8 years ago

Can there be an official update pushed to npm?

luje commented 8 years ago

I am using "cordova-plugin-facebook4" spec="~1.7.1" and "cordova-plugin-googleplus" spec="~4.0.0".

I've had the same issue. Along with fixing the versions for the play-services-plus and play-services-identity libraries, i've also had to specify the com.google.android.gms:play-services-auth:9.0.2

gpini commented 8 years ago

The problem for me appeared while updating Google Repository package in Android SDK from version 25 to version 31. Unfortunately there is no way to downgrade SDK packages. I have reproduced the issue also in another PC. The workaround setting google dependencies to version 9.0.2 doesn't work for me.

luje commented 8 years ago

I tried to force all dependencies to 9.0.2 by using build-extras.gradle mechanism in cordova. The build works but the debug apk fails at runtime with no method found exceptions. Apparently the plus-services packages also have transitive dependencies which are unbounded (so they retrieve the latest versions 9.2.1 in my case at the moment).

GwenWing commented 8 years ago

Same here, forcing dependencies to 9.0.2 doesn't help. This issue is really annoying.

luje commented 8 years ago

So... now i have this:

dependencies { compile ("com.google.android.gms:play-services-auth:9.0.2") {force = true} compile ("com.google.android.gms:play-services-plus:9.0.2") {force = true} compile ("com.google.android.gms:play-services-identity:9.0.2") {force = true} compile ("com.google.android.gms:play-services-gcm:9.0.2") {force = true} compile ("com.google.android.gms:play-services-base:9.0.2") {force = true} compile ("com.google.android.gms:play-services-basement:9.0.2") {force = true} compile ("com.google.android.gms:play-services-tasks:9.0.2") {force = true} }

in platforms/android/build-extras.gradle (create this file if it doesn't exist)

And i have ''

And it works.

GwenWing commented 8 years ago

I tried you fix, but it doesn't work for me unfortunately. I've even tried to reinstall plugin before applying the fix but no luck.

rwasef1830 commented 8 years ago

I fixed this problem by using the git version of the plugin and removing / readding the android platform to force redownload of the plugin. The new plugin version does not have any dependency on the missing package. Just changing the URL in ionic config file didn't fix it for me, you have to force it to redownload and readd the plugin.

The missing package is because Google Plus SDK is deprecated by Google for a long time and they finally removed it in new SDK versions.

luje commented 8 years ago

I have a setup where i allways clean the platforms and plugins folders and make changes afterwards with cordova hooks (it's still a young project). I imagined that this is what everybody does :)

GwenWing commented 8 years ago

Do you mean you are removing/reinstalling all cordova plugins for your cleaning?

Le 15 juil. 2016 ? 13:28, luje notifications@github.com<mailto:notifications@github.com> a ?crit :

I have a setup where i allways clean the platforms and plugins folders and make changes afterwards with cordova hooks (it's still a young project). I imagined that this is what everybody does :)

You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/252#issuecomment-232928396, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKEhRNgPmOefgJB3efQkrPqY28B3wei-ks5qV27sgaJpZM4JAi1X.

luje commented 8 years ago

Yes. For the jenkins CI job at least.. but i do this localy only if i have issue adding/removing new plugins. Just for consistency.

GwenWing commented 8 years ago

Still no luck with it. Can you tell me which Cordova version, and cordova android plateform version you are using?

luje commented 8 years ago

cordova 6.2.0

GwenWing commented 8 years ago

same here :-/

amiriltd commented 8 years ago

I am using PhoneGap cli-5.4.1 and there is no version on GIT that has committed to using version 9.0.2 version of googleplus. Also, PhoneGap claimed we should be able to use branches and that does not work (this is a Phonegap issue) as I tried to use Gotev's version ie "patch-1"

gpini commented 8 years ago

It works for me changing platforms/android/build.gradle in "dependencies" section through Android Studio. I had to change the version of every package depending on "com.google.android.gms" For example "com.google.android.gms:play-services-plus:=+" to "com.google.android.gms:play-services-plus:9.0.2" and so on with all gms packages. Please note that the change must be repeated every time that you remove and readd platform.

GwenWing commented 8 years ago

Thank you for this feedback. Can you list us Android SDK packages (including Google play services SDK) versions you are using?

Cheers

Le 19 juil. 2016 ? 16:20, Giovanni Pini notifications@github.com<mailto:notifications@github.com> a ?crit :

It works for me changing platforms/android/build.gradle in "dependencies" section through Android Studio. I had to change the version of every package depending on "com.google.android.gms" For example "com.google.android.gms:play-services-plus:=+" to "com.google.android.gms:play-services-plus:9.0.2" and so on whit all gms packages. Please note that the change must be repeated every time that you remove and readd platform.

You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/252#issuecomment-233647600, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AKEhRAB7AUIVvMC61cxDajwKOrxyp93Vks5qXN0NgaJpZM4JAi1X.

gpini commented 8 years ago

@GwenWing I'm using:

I'm not using Google Play Service package.

GwenWing commented 8 years ago

@gpini thanks! I've checked my versions and the only difference is Android Support Repository, I have v34. Not found a way to downgrade this package.

Did some further testing with "com.google.android.gms:play-services-plus:9.0" and the "signed for release" built package:

What I understand so far from these tests is that:

Also I see in logs several Java exception related to some Google services, but I don't find a way to make sure it is related to this issue...

E/Parcel ( 553): Class not found when unmarshalling: com.google.android.gms.auth.api.signin.internal.SignInConfiguration E/Parcel ( 553): java.lang.ClassNotFoundException: com.google.android.gms.auth.api.signin.internal.SignInConfiguration E/Parcel ( 553): at java.lang.Class.classForName(Native Method) E/Parcel ( 553): at java.lang.Class.forName(Class.java:251) E/Parcel ( 553): at java.lang.Class.forName(Class.java:216) ...

And this one, that seems to be related to the GooglePlus plugin: E/Parcel ( 553): Class not found when unmarshalling: com.google.android.gms.common.api.Scope E/Parcel ( 553): java.lang.ClassNotFoundException: com.google.android.gms.common.api.Scope E/Parcel ( 553): at java.lang.Class.classForName(Native Method) E/Parcel ( 553): at java.lang.Class.forName(Class.java:251) E/Parcel ( 553): at java.lang.Class.forName(Class.java:216) E/Parcel ( 553): at android.os.Parcel.readParcelableCreator(Parcel.java:2140) E/Parcel ( 553): at android.os.Parcel.readParcelable(Parcel.java:2104) E/Parcel ( 553): at android.os.Parcel.readParcelableArray(Parcel.java:2197) E/Parcel ( 553): at android.os.Parcel.readValue(Parcel.java:2074) E/Parcel ( 553): at android.os.Parcel.readArrayMapInternal(Parcel.java:2321) E/Parcel ( 553): at android.os.Bundle.unparcel(Bundle.java:249) E/Parcel ( 553): at android.os.Bundle.getString(Bundle.java:1118) E/Parcel ( 553): at android.content.Intent.getStringExtra(Intent.java:5209) E/Parcel ( 553): at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1467) E/Parcel ( 553): at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1063) E/Parcel ( 553): at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:4385) E/Parcel ( 553): at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:254) E/Parcel ( 553): at com.android.server.am.ActivityManagerService.startActivityIntentSender(ActivityManagerService.java:4266) E/Parcel ( 553): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:269) E/Parcel ( 553): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2712) E/Parcel ( 553): at android.os.Binder.execTransact(Binder.java:404) E/Parcel ( 553): at dalvik.system.NativeStart.run(Native Method) E/Parcel ( 553): Caused by: java.lang.NoClassDefFoundError: com/google/android/gms/common/api/Scope E/Parcel ( 553): ... 20 more E/Parcel ( 553): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.api.Scope" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /sy\ stem/lib, /lib]]

So still stuck and no idea what to explore next... :)

amiriltd commented 8 years ago

This is still not working for PhoneGap.

GwenWing commented 8 years ago

Good news: I finally succeed to rebuild and have GooglePlus plugin work on Android with latest Android SDK APIs installed.

The trick for me has been to force the use of 4.0.8 plugin from NPM install, instead of 4.0.9 from GIT pull.

config.xml after reinstall: ... <plugin name="cordova-plugin-googleplus" spec="~4.0.8"> <variable name="REVERSED_CLIENT_ID" ...

And I have this config in build-extras.gradle:

`dependencies {

compile ("com.google.android.gms:play-services-auth:9.0.2") {force = true} compile ("com.google.android.gms:play-services-identity:9.0.2") {force = true} compile ("com.google.android.gms:play-services-plus:9.0.2") {force = true} } `

sammugg commented 8 years ago

@GwenWing, Please be aware that the google plus authentication package (play-services-plus) is deprecated for iOS. On the Android guide page, Google has posted the following note:

"If you only want to sign in your users with their Google Accounts, and do not need to use any Google+ features, integrate Google Sign-In into your app without requesting the Google+ scopes as described below."

Our efforts with 4.0.9 were to improve the Android side and use Sign-In instead of Google+.

Remember: If you have made changes to the plugin that helped make it work in your environment, create a Pull Request! This is an Open Source project, so it will only get better if people keep contributing to it.

GwenWing commented 8 years ago

OK but so far, I had absolutely no luck to have 4.0.9 package work on Android (it works with iOS though)

luje commented 8 years ago

I think what sammuggPS is trying to say is that the line:

compile ("com.google.android.gms:play-services-plus:9.0.2") {force = true}

should not be included in build-extras.gradle. I personally added it because 4.0.8 version of this plugin was referencing play-service-plus and the dependency tree was retrieving version 9.2.1 (i think.. not sure) but with 4.0.9 it's not necessary.

SreeharshaJois commented 8 years ago

Replace

<framework` src="com.google.android.gms:play-services-plus:+" />
<framework src="com.google.android.gms:play-services-identity:+" />

with

<framework` src="com.google.android.gms:play-services-plus:9.0.2" />
<framework src="com.google.android.gms:play-services-identity:9.0.2" />

in both plugin.xml as well as platforms/android/project.properties. In my case if I replace only plugin.xml then build.gradle was getting overridden with project.properties content and + version was being used instead of specific version

sammugg commented 8 years ago

Make sure that you have the following items installed and up-to-date in your SDK manager:

  1. SDK Tools (latest)
  2. Platform-tools (latest)
  3. Build-tools (latest)
  4. API 23 or less (Cordova 6.x and Cordova-android 5.x only support up to 23) with the following:
    1. SDK Platform (keep up to date)
    2. An emulator image that includes Google APIs (i.e. Google APIs Intel x86 Atom System Image)
    3. Google APIs (the standalone install)
  5. Android Support Repo (latest)
  6. Google Play Services (latest)
  7. Google Repository (latest)

I just built and ran a POC app using v4.0.9 of this plugin (which has play-services-auth:+ and play-services-identity:+ in the plugin.xml). Everything worked properly.

Other POC info: API version 23 Latest versions of all "latest" items listed above Running on Emulator: Google APIs Intel x86 Atom_64 System Image Cordova: v6.3.0 Cordova-android: v5.2.1 Java JDK: 1.8.0_102

amiriltd commented 8 years ago

@sammuggPS any advice for those using phonegap?

sammugg commented 8 years ago

I'll need to revisit phonegap and ionic in the near future. I started a POC on those but work picked up so I had to set it aside.

amiriltd commented 8 years ago

@sammuggPS I solved my issue by removing the "isAvailable" references in my code

sammugg commented 8 years ago

@amiriltd Really? Interesting. Are you using v4.0.8 of the plugin? Have you tried using v4.0.9? It's more up to date with Google's practices and SDK.

amiriltd commented 8 years ago

@sammuggPS I am using Ristken's version of the plugin https://github.com/Ristken/cordova-plugin-googleplus

I would imagine that I could use EddyVerbruggen's version and be fine as well

rajendratodkari commented 8 years ago

For Ionic Projects

Real Issue : Android SDK upgrade

Fix :

In following files :

platforms/android/build.gradle platforms/android/project.properties platforms/android/cordova/lib/builders/GradleBuilder.js plugins/cordova-plugin-googleplus/plugin.xml plugins/cordova-plugin-google-analytics/plugin.xml

Change wherever applicable

FROM

cordova.system.library.1=com.google.android.gms:play-services-plus:+ cordova.system.library.2=com.google.android.gms:play-services-identity:+ cordova.system.library.3=com.google.android.gms:play-services-analytics:+

TO

cordova.system.library.1=com.google.android.gms:play-services-plus:9.0.2 cordova.system.library.2=com.google.android.gms:play-services-identity:9.0.2 cordova.system.library.3=com.google.android.gms:play-services-analytics:9.0.2

sammugg commented 8 years ago

@rajendratodkari What do you mean by the "Real Issue" is an Android SDK upgrade? Would like some clarity b/c a lot of people have been using Ionic with no luck.

risleylima commented 8 years ago

This happened to me when I upgraded to the last updates of Google on SDK manager.

So, I removed the plugin and reinstalled using the "Github way" instead the "Formal Way":

cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --save --variable REVERSED_CLIENT_ID=myreversedclientid

cordova prepare

And the build was successful, maybe this is the simplest way.

sammugg commented 8 years ago

@risleylima, are you using Ionic?

risleylima commented 8 years ago

Yep, this is my build system info:

Cordova CLI: 6.3.0 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.11 Ionic CLI Version: 2.0.0-beta.36 Ionic App Lib Version: 2.0.0-beta.19 ios-deploy version: 1.8.6 ios-sim version: 5.0.8 OS: Mac OS X El Capitan Node Version: v5.10.1 Xcode version: Xcode 7.3.1 Build version 7D1014

sammugg commented 8 years ago

Awesome! Glad you got it working. If you have any tips for other people surrounding setup for Ionic, feel free to post them!

Lots of people have been using it. I think one of the common issues is that ionic uses a different SHA1 than the default debug keystore one.

risleylima commented 8 years ago

@sammuggPS, about the SHA1 issue, for me the app has 2 different SHA1.

1 for the debug apk, which is the default debug keystore. 1 for the production apk, which I have created and signed manually the apk after build for production.

In credentials, on google developer console, I uploaded the 2 SHA1, and installed the plugin only with the production reversed client ID, generated by google with my production SHA1.

Cordova installed the plugin automatically in my Android and iOS platforms.

Note that I installed the plugin with the cordova CLI and not with the Ionic CLI, when I installed with Ionic CLI I had some problems too.

Then, for the iOS build, I only created on google console the credential using the package ID.

For some reason, this approach worked for all my builds: Production and Debug for Android and iOS.

The version 2 of Ionic uses TypeScript to compile the javascript code. When I typed in my code the call to your plugin functions, the TypeScript throw an error, because the functions are unknown to the ambient. So I created a simple TypeScript Definition file to describe only the functions that I'm using of your plugin and pointed the TypeScript to read the file, everything worked correctly.

To make the TypeScript Definition available for the users, I recommend to upload the Definition file created to the "DefinitelyTyped" repository on github.

This repository is readable by one tool available in NodeJS: Typings.

Unfortunately, I don't know how to update, or if is available a more simple solution for the TypeScript problem, but I had the file that I created, if you wish I can send to you, but its very simple...

Sorry for my poor English. 😄

sammugg commented 8 years ago

@risleylima thank you for the details!

If you wanted to be awesome, could you add some info to the README of this project and make a Pull Request? It would be even more awesome if you could include that TypeScript Definition with the PR!!!

risleylima commented 8 years ago

No problem! I haven't figured out how to do yet 😖

But I will, and so I learn, I will make the PR!

Thanks.

zigzag-way commented 8 years ago

Still have the same problem and can not fix it (

risleylima commented 8 years ago

@zigzag-way, if you have the "npm version" installed, try to remove the plugin, and install the "GitHub version", the README has the command to install this version, wich is the latest version.

Maybe doing this will solve your problem.

spradnyesh commented 8 years ago

things that have worked for me