Giter VIP home page Giter VIP logo

react-native-google-sign-in's Introduction

React Native Wrapper for Latest Google Sign-In SDK

https://github.com/devfd/react-native-google-signin is not working and is not being maintained anymore (See Issue), so I created this one myself. It uses the latest Google Sign-In SDK.

For LinkedIn SDK, check out joonhocho/react-native-linkedin-sdk

Getting started

Tested with React Native 0.39 and 0.40. Also, see Tested Environments. Let me know if some instructions are missing.

$ react-native install react-native-google-sign-in

Android

Follow Google's official instructions for Android.

Follow everything from the instructions with the following modifications. Some of the following modifications should be done by react-native install automatically. If not, do it yourself:

  • Move google-services.json to {YourApp}/android/app/google-services.json.

  • Add to your {YourApp}/android/settings.gradle:

include ':react-native-google-sign-in'
project(':react-native-google-sign-in').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-sign-in/android')
  • Modify your {YourApp}/android/build.gradle:
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3' // This may need to be updated to >= 2.2.3.
    classpath 'com.google.gms:google-services:3.0.0' // Add this
}
  • Modify your {YourApp}/android/app/build.gradle:
dependencies {
    compile(project(":react-native-google-sign-in")) { // ADD this
        exclude group: "com.google.android.gms"
    } 
    ...your modules...
    compile "com.google.android.gms:play-services-auth:10.0.1" // Add this, not 9.8.0 (from instructions).
    compile "com.facebook.react:react-native:+"
}

apply plugin: "com.google.gms.google-services" // Add this after dependencies.
  • Modify your {YourApp}/android/app/src/main/java/com/{YourApp}/MainApplication.java:
import com.reactlibrary.googlesignin.RNGoogleSignInPackage; // Add this.

...in your class MainApplication...
        @Override
        protected List<ReactPackage> getPackages() {
            return Arrays.<ReactPackage>asList(
                    new MainReactPackage(),
                    new RNGoogleSignInPackage(), // Add this.
                    ...other packages...
            );
        }

iOS

(prerequisite) Setup Swift Bridging Header

  • Make sure you have a Swift Bridging Header for your project. Here's how to create one if you don't.

Manually download and install Google SignIn SDK (Without CocoaPods)

  • At the time of writing, Google Sign-In SDK 4.1.0 is the latest.

  • Follow Google's official instructions, Install Google SDK WITHOUT CocoaPods. I could not get it working with CocoaPods.

  • It's important to follow every instruction!

  • Make sure to properly add the following frameworks according to the Google's instructions:

    • GoogleSignIn.bundle
    • GoogleSignIn.framework
    • GoogleSignInDependencies.framework
    • SystemConfiguration.framework
    • SafariServices.framework
  • Here are some screenshots that shows proper installations (Refer to ExampleApp):

  • Open up your project in xcode and right click the package.

  • Click Add files to '{YourApp}'.

  • Select to {YourApp}/node_modules/react-native-google-sign-in/ios/RNGoogleSignIn.

  • Click 'Add'.

  • Click your project in the navigator on the left and go to Build Settings.

  • Search for Header Search Paths.

  • Double click on the value column.

  • Add $(SRCROOT)/../node_modules/react-native-google-sign-in/ios/RNGoogleSignIn.

  • Screenshots:

Add to your {YourApp}/ios/{YourApp}/AppDelegate.m:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // ADD THE FOLLOWING CODE
  NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
  NSDictionary *plistDict = [NSDictionary dictionaryWithContentsOfFile:filePath];
  [GIDSignIn sharedInstance].clientID = [plistDict objectForKey:@"CLIENT_ID"];
  // ADD THE ABOVE CODE
  ...your code
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  // ADD THE FOLLOWING CODE
  BOOL handled = [[GIDSignIn sharedInstance] handleURL:url
                                     sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                            annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
  return handled;
  // ADD THE ABOVE CODE
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
  // ADD THE FOLLOWING CODE
  if ([[GIDSignIn sharedInstance] handleURL:url
                          sourceApplication:sourceApplication
                                 annotation:annotation]) {
    return YES;
  }
  // ADD THE ABOVE CODE
  return YES;
}

Add to your {YourApp}/ios/{YourApp}/AppDelegate.h:

#import <GoogleSignIn/GoogleSignIn.h>

Add to your Swift Bridging Header, {YourApp}/ios/{YourApp}-Bridging-Header.h:

#import <React/RCTBridgeModule.h>
#import <React/RCTViewManager.h>
#import <React/RCTEventEmitter.h>
#import <GoogleSignIn/GoogleSignIn.h>

Or, if you are using RN <= 0.39:

#import "RCTBridgeModule.h"
#import "RCTViewManager.h"
#import "RCTEventEmitter.h"
#import <GoogleSignIn/GoogleSignIn.h>

Usage

import GoogleSignIn from 'react-native-google-sign-in';

// later in your code...
async yourMethod() {
  await GoogleSignIn.configure({
    // iOS
    clientID: 'yourClientID',

    // iOS, Android
    // https://developers.google.com/identity/protocols/googlescopes
    scopes: ['your', 'requested', 'api', 'scopes'],

    // iOS, Android
    // Whether to request email and basic profile.
    // [Default: true]
    // https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a06bf16b507496b126d25ea909d366ba4
    shouldFetchBasicProfile: boolean,

    // iOS
    // https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a486c8df263ca799bea18ebe5430dbdf7
    language: string,

    // iOS
    // https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a0a68c7504c31ab0b728432565f6e33fd
    loginHint: string,

    // iOS, Android
    // https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#ae214ed831bb93a06d8d9c3692d5b35f9
    serverClientID: 'yourServerClientID',

    // Android
    // Whether to request server auth code. Make sure to provide `serverClientID`.
    // https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInOptions.Builder.html#requestServerAuthCode(java.lang.String, boolean)
    offlineAccess: boolean,
    
    // Android
    // Whether to force code for refresh token.
    // https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInOptions.Builder.html#requestServerAuthCode(java.lang.String, boolean)
    forceCodeForRefreshToken: boolean,

    // iOS
    // https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a211c074872cd542eda53f696c5eef871
    openIDRealm: string,

    // Android
    // https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInOptions.Builder.html#setAccountName(java.lang.String)
    accountName: 'yourServerAccountName',

    // iOS, Android
    // https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#a6d85d14588e8bf21a4fcf63e869e3be3
    hostedDomain: 'yourHostedDomain',
  });

  const user = await GoogleSignIn.signInPromise();

  console.log(user);
}

See js/GoogleSignIn.ios.js for supported iOS APIs.

See js/GoogleSignIn.android.js for supported Android APIs.

Tested Environments

I only tested with the following environments:

  • Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1) / Target: x86_64-apple-macosx10.9
  • Xcode Version 8.2.1 (8C1002)
  • Android Studio 2.2.3 / Build #AI-145.3537739, built on December 2, 2016 / JRE: 1.8.0_112-release-b05 x86_64 / JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

LICENSE

The MIT License (MIT)

Copyright (c) 2017 Joon Ho Cho

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

react-native-google-sign-in's People

Contributors

grigored avatar ivpusic avatar joonhocho avatar maciej-rosiek avatar sarovin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-google-sign-in's Issues

Question for the IOS framework

Hi Thanks for the nice work.

Just wandering is there a reason need to wrap the sign in method in side the dipsatch.main.aysnc ?
?

How do I know if a user is already logged in when my app starts?

Hi
I don't want to force the user to log in each time my (Android) App starts.
Basically my App offers Facebook and Google Login the first time it starts.
Once the user logged in with Facebook or Google the app should remember this.
Next time the user starts my app he should be already logged in.

The react-native-facebook-login calls an onLoginFound callback which tells my app if the user is already logged in to my app.

How do I achieve the same with react-native-google-sign-in ?

@stami

Android get a rejection on configure with error code : 2

Hi, first of all, thank you for the great work !

I open this issue because I'm having an error 2 rejection when calling configure without any error message so I don't know what's wrong in my configuration. :/

I'm using RN 0.39 and I'm calling configure with the following arguments:

await GoogleSignIn.configure({
clientID: Platform.os === 'ios' ? '[myKey].apps.googleusercontent.com' : null,
shouldFetchBasicProfile: true,
serverClientID: '[myServerKey].apps.googleusercontent.com',
offlineAccess: true,
}).catch(err => {
    console.log('err', err);
});

And the console.log gets:

{
    code: 2
}

This code works just fine on iOS but not in Android and I don't know what I'm doing wrong... :/

If somebody knows what error code 2 is, can you help me please ?

Thank you in advance and once again, great work !

Is this still being mantained?

Just wanted to know if this module still works and if its being mantained so I can know if I need to find another module or fork this one. Thanks!

Build Failed: com.android.dex.DexException

I followed exactly all setup instructions on a brand new macOS with brand new react-native 0.45.1 and checked that all files are as described in the README. But running react-native run-android build fails with the following error:

Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
        at com.android.dx.command.dexer.Main.run(Main.java:277)
        at com.android.dx.command.dexer.Main.main(Main.java:245)
        at com.android.dx.command.Main.main(Main.java:106)
    
:app:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Is there a way to fix this?

Refresh accessToken or tokenID

Hi,

Your plugin works well, thank you very much, however I want to refresh accessToken and tokenID when it expired, how can I do that?

Thanks

normalizeUser not called on iOS when currentUser exists

In

async signInPromise() {
  const user = await RNGoogleSignIn.currentUser();
  if (user) return user;

  ...
},

The first lines should probably be:

const user = await RNGoogleSignIn.currentUser();
if (user) return GoogleSignIn.normalizeUser(user);

Now two different kinds of objects are returned.

Thanks it works but how can I make a log out?

Btw I had a problem it only worked for me after adding this to my dependencies:
compile(project(":react-native-google-sign-in")){
exclude group: "com.google.android.gms"
}

please let me know how to make a log out
Thanks

GoogleSigninError: A non-recoverable sign in failure occurred

Hello,
I am using this module for google signin and it gives below error.
{ [GoogleSigninError: A non-recoverable sign in failure occurred] name: 'GoogleSigninError', code: 12500 }.

I have completed all the steps.
Google sign in dialog box is opening but after click on email, it gives above error.
Please Help
Thanks

Couple of updates to get things compiling etc

Here are a few things I needed to do to get things loading properly

  1. Needed to add: classpath 'com.google.gms:google-services:3.0.0' to android/build.gradle (otherwise it wouldn't even build the apk)

  2. Fixed compile error about react-native-google-sign-in/iindex.js, by adding Export transform extension: http://babeljs.io/docs/plugins/transform-export-extensions/ (see: #1 )

  3. My react-native install didn't seem to link things properly (it just added import to MainActivity.java), so had to manually modify MainApplication.java as below:

import com.reactlibrary.googlesignin.RNGoogleSignInPackage; // Add this
...
public class MainApplication extends Application implements ReactApplication {

@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),          
          new RNGoogleSignInPackage() // Add this
      );
    }
...

Also, would be useful to indicate which of the configure options are required and which ones are optional. So far only specified scopes and it seems to be working.

'Google/SignIn.h' file not found

I created Swift Bridging Header

#import <Google/SignIn.h> still has error

'Google/SignIn.h' file not found occurred in Bridging Header

anyone can help?

signoutpromise broken (iOS)

I think signout promise never resolves, because you're listening for disconnect events.

If just doing a sign out, the user will only be signed out locally and the disconnect events never raise.

Just calling .signOut doesn't work either, as this is dispatched async on iOS, so the function returns before the user is signed out.

For my own workaround, I've removed the async dispatch in signOut https://github.com/YousefED/react-native-google-sign-in/blob/master/ios/RNGoogleSignIn/RNGoogleSignIn.swift. Not sure this is the correct solution, but seems to be working for our use case now

Struggling to get the imports to work in objective C

Hi,

I've followed the guide, enabled swift in my OOTB objc project but I'm struggling to get the library to work in react native. I'm fairly certain it's because of an import problem.

The xcode project builds fine but when the javascript loads I get the following error.

Native module cannot be null.

NativeEventEmitter
    NativeEventEmitter.js:32
<unknown>
    GoogleSignIn.ios.js:12
loadModuleImplementation
    require.js:171
<unknown>
    index.js:1
loadModuleImplementation
    require.js:171
<unknown>
    LoginPage.js:16
loadModuleImplementation
    require.js:171
<unknown>
    RootRouter.js:14
loadModuleImplementation
    require.js:171
<unknown>
    index.ios.js:18
loadModuleImplementation
    require.js:171
guardedLoadModule
    require.js:116
global code
    require-0.js:1

I know you have only tested it in swift but I'd appreciate any help you could give getting it to work in objc.

Thanks

deploy using react-native run-ios

On deploying using

react-native run-ios

it gives an error of native module cannot be null.
Whereas on running it through Xcode using .xcworkspace file it works, although it takes a lot of time to build.
Is there any way in which I can deploy it like usual through command line without having to open Xcode each time to deploy, similar to your example app?
As running 2 of 4 custom shell scripts takes a lot of time during build.

Also on side note the client id for IOS and android are different and following ones should be selected
Android from google-service.json

"oauth_client": [
      {
        "client_id": "ThisID",
        "client_type": 1,
        "android_info": {
          "package_name": "package name",
          "certificate_hash": "hashmap"
        }
      },

Ios from GoogleService-Info.plist

<key>CLIENT_ID</key>
	<string>ThisId</string>

Replace those Id here

await GoogleSignIn.configure({
                            clientID: 'ThatId',
                            scopes: ['openid', 'email', 'profile'],
                            shouldFetchBasicProfile: true,
                        });

Not compiling on iOS Emulator (Undefined symbols for architecture x86_64)

I'm having this error when trying to compile on iOS Emulator:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RNGoogleSignIn", referenced from:
      l_OBJC_$_CATEGORY_RNGoogleSignIn_$_RCTExternModule in RNGoogleSignInBridge.o
  "_OBJC_CLASS_$_RNGoogleSignInEvents", referenced from:
      l_OBJC_$_CATEGORY_RNGoogleSignInEvents_$_RCTExternModule in RNGoogleSignInEventsBridge.o
ld: symbol(s) not found for architecture x86_64

Anyone knows how to solve this?

library failed to import bridging header

I created another build configuration => "Staging", and when building with this configuration I get following error

failed to import bridging header '/Users/ipusic/xxxxxxx/node_modules/react-native-google-sign-in/ios/RNGoogleSignIn/RNGoogleSignIn-Bridging-Header.h'

Android: Unhandled Promise Rejection

  async googleSignIn() {

      await GoogleSignIn.configure({
        clientID: "MY CLIENT ID",
        scopes: ['profile', 'email', 'openid'],
        shouldFetchBasicProfile: true,
      });

    var user = await GoogleSignIn.signInPromise();

    setTimeout(() => {
      alert(JSON.stringify(user, null, '  '));
    }, 1500);

  }

i got Unhandled Promise Rejection

Possible Unhandled Promise Rejection

Documentation Suggestion for RN 0.39

Overall, awesome directions! Really appreciate the details on how to get the library up and running.

Since you mention that you tested on RN 0.39, I might encourage you to add a section in the in Getting Started section for iOS that says if you are still using RN 0.39, your {YourApp}/ios/{YourApp}-Bridging-Header.h needs to look like this instead:

#import "RCTBridgeModule.h"
#import "RCTViewManager.h"
#import "RCTEventEmitter.h"
#import <Google/SignIn.h>

[IOS] Missing iOS app ClientID - [SOLVED]

Hi all,

I just want to share the info.

To make google signin work on iOS, you need to add iosClientId instead of clientID like in the documentation.

GoogleSignin.configure({
      iosClientId: '<your clientID>',
      scopes: ['openid', 'email', 'profile'],
      shouldFetchBasicProfile: true
})

Hope this help

Wrong property name "RNGoogleSignIn"

Please change it to "RNGoogleSignin" with a small letter "i", this wasted several hours of mine, damn!

Edit: It's giving undefined error with capital letter "I" as there is no such property on NativeModules when inspected using chrome debugger.

iOS GGLContext issue

When building its showing error
installed pods
pod 'GoogleSignIn'
pod 'GoogleAnalytics'
Xcode 8.3.2
"react": "^16.0.0-alpha.12",
"react-native": "^0.48.3",
screenshot at nov 09 15-44-27
"react-native-google-sign-in": "0.0.8",

Compilation errors (iOS)

I'm having lot of errors when trying to compile the app (40 errors, file: RNGoogleSignIn.swift). Has anyone had the same problem?
Xcode 8.2.1
RN 0.4

SS:
captura de pantalla 2017-03-01 a las 11 00 41 p m

DeveloperERROR

What is DEVELOPER ERROR?
i am getting {Error:DEVELOPER_ERROR,code:10}

Having NSError @com.google.greenhouse code:106

I'm implementing react-native-google-sign-in on my project and

I am stuck due to this error.

Is there any solution for it?

this is the error code:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error configuring Google services: Error Domain=com.google.greenhouse Code=-106 "Missing expected subspecs." UserInfo={NSLocalizedDescription=Missing expected subspecs., NSLocalizedFailureReason=Some subspecs are not pod installed. See log for details.}'

thank you!

I can't get the iOS project to build

It gives me an error like this:

ld: warning: directory not found for option '-F/Users/sakarit/repositories/xxx/ios/Build/Products/Debug-iphonesimulator/GTMOAuth2'
ld: warning: directory not found for option '-F/Users/sakarit/repositories/xxx/ios/Build/Products/Debug-iphonesimulator/GTMSessionFetcher'
ld: warning: directory not found for option '-F/Users/sakarit/repositories/xxx/ios/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac'
ld: framework not found GTMOAuth2
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do you have any idea what could be wrong?

Build error when running `react-native run-android` in `:app:transformClassesWithDexForDebug`

After setting up the android side of the project and trying to run it I get the following error:

:app:transformClassesWithDexForDebug
Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb$1;
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/google/firebase/iid/zzb$1;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
        at com.android.dx.command.dexer.Main.run(Main.java:277)
        at com.android.dx.command.dexer.Main.main(Main.java:245)
        at com.android.dx.command.Main.main(Main.java:106)

:app:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to getmore log output.

BUILD FAILED

I can't figure out what is going wrong, any help would be greatly appreciated :)

Google signin issue with Firebase Issue on Android

Hi Guys,

First of all I found that someone already posted this issue before and the link can be found #here

my problem is I'm not sure what's my serverClientID , I tried researching on the doc reference posted on the pages as well research it but I could not located it on google console or in any configuration that google provide. The only thing I have was the clientID which I tried to use it on serverClientID but it is not working.

the error issue return is
Cannot find GOOGLE appId for project: 6337043635669.
I already added the clientID on firebase "Whitelist client IDs from external projects"

also here is my configuration
await GoogleSignIn.configure({ clientID: 'XXXXXXXXXXXXX', serverClientID: 'XXXXXXXXXXXXX', scopes: ['email', 'profile'], shouldFetchBasicProfile: true });
Note: I did add openid on the scope and still didn't work.

thanks,

Native Module cannot be null

I have followed the directions for both IOS and Android. When I simply try to import it via:
import GoogleSignIn from 'react-native-google-sign-in';
react native throws this error: Requiring module "react-native-google-sign-in/js/GoogleSignIn.ios.js" which threw an exception: Invariant Violation: Native module cannot be null.
no idea why this is happening or why this is not working with an import, cannot find any documentation to this error before or if anyone else is having this issue as well.

Compile error

I can't seem to compile and keep getting the error 'react-native-google-sign-in/index.js: Unexpected token, expected ; (1:20)'

New googlesignin pod

In order to match other dependencies that I have I had to switch to the newer google pod:
pod 'GoogleSignIn'

In order to use that the imports have to be changed to:
#import <GoogleSignin/GoogleSignIn.h>

And the config in didFinishLaunchingWithOptions to:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
NSDictionary *plistDict = [NSDictionary dictionaryWithContentsOfFile:filePath];
[GIDSignIn sharedInstance].clientID = [plistDict objectForKey:@"CLIENT_ID"];

Hopefully that helps someone.

Unkown status code 12501

When using your module, I get the following object instead of the correct user:

Object {error: "unknown status code: 12501", code: 12501}

Do you have an idea why ?

GoogleSignIn.configure throws error : {code: 9}

I am getting an error {code: 9} when calling GoogleSignIn.configure like this:

                    try {
                        await GoogleSignIn.configure({
                            clientID: '479733430993-bd4an7eqo052v3sg0p0cop2aavqek3nb.apps.googleusercontent.com',
                            scopes: ['openid', 'email', 'profile'],
                            shouldFetchBasicProfile: true,
                        });
                    } catch (ex) {
                        console.log('Y1', ex);
                    }

This is the error I observe:

Y1 Object {code: 9}

Does anybody know what {code: 9} means and how to fix it?

react native configuration with name 'default' not found

Hi!

Having followed the installation guide step by step I kept getting the error mentioned in the subj when cleaning / building my app. It turned out that the lib subdirectory in node_modules wasn't created by $ react-native install react-native-google-sign-in. When I used npm install it worked like a charm. Linking is needed of course.

It seems to be a bug with react-native install but it took hours for me to find it out. Maybe you would find it appropriate to mention it in the readme.

Thanks for your work,
Robin.

accessToken not working with Firebase

hi, firstly a big thank you for publishing this - awesome stuff !

ive got it setup and working fine for ios.

on android, i am successfully getting an auth response - however the idToken is null and the accessToken isn't working -- when i try to use it to auth w/ firebase.

my first thought was should the idToken be null (on android)? on iOS the idToken has a value, which then works when auth'ing to firebase

thanks for your help

Buildtime swift compiler errors in xCode

I am facing buildtime swift compiler 41 errors in xCode, please see attached. I have Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42) on my mac.

Any help will be appreciable.
screen shot 2017-09-08 at 3 50 00 pm

Error with cocoa pods plz help

Hi, im new in Xcode, im trying to install google firebase with cocoa pods and when going to compile I have this issue

Apple Mach-O Linker (ld) Error Group
clang: error: linker command failed with exit code 1 (use -v to see invocation)

when I run pod install I have this warnings too

[!] The reactApp [Debug] target overrides the FRAMEWORK_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-reactApp/Pods-reactApp.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the $(inherited)` flag, or
- Remove the build settings from the target.

please be very specific with yours answers, remember im noob with Xcode

Native module cannot be null

I followed the steps exactly mentioned in the docs but I am getting native module cannot be null while using this package. Any help please?

Sign out doesn't work on Android

First, thank you for the module, great work!

I cannot perform signing out on Android. When I call await GoogleSignIn.signOutPromise() and delete the storage related to last signed user and try to sign in with the same user again, I get the following message: This account already exists on your device. On iOS this works.

EDIT: I think when I log in, the system has to prompt me with a dialog where I can choose already registered account.

SignIn idToken

The idToken I get from the SignIn response is null on Android but correct on iOS. It's successfully signing me in on Android as all of the other fields seem to be populated (eg I get an accessToken). This is my code for both iOS and Android:

const config = {
    clientID: GoogleConfig.ClientIdIOS,
    scopes: ['profile', 'email', 'openid'],
    shouldFetchBasicProfile: true,
}

GoogleSignIn.configure(config).then(
    () => {
        GoogleSignIn.signInPromise().then(...)
    ...

Maybe I'm missing something I need in config? It seems in the documentation for Google SignIn I may need to include the serverClientID in the config?

Stuck on blank white screen on second GoogleSignIn.signIn()

I'm noticing that in certain situations, the second time I call GoogleSignIn.signIn(), the app gets stuck on a blank white screen. It works fine the first time through, but the second time I call it, it looks like it's sliding over to the web view screen, but it's solid white. Once it's there, React Native's Reload does not fix the blank screen. I have to kill the app and re-run it.

It was working fine when I was calling it from a onPress callback. But recently I added a react-native-material-dialog popup and call it from there. I just moved the same handler function from the button component to the dialog component. I don't see anything fancy in the MaterialDialog component. It's just a wrapper around a standard React Native Modal component.

Any ideas what might be causing this? Hints on a workaround, or ways to debug it? Thanks!

[feature] refresh access token

A way to refresh and getting a new access token would be handy!

Just a promisify call with new token would be enough :)

"Native module cannot be null" on iOS, RN v0.43.3

After linking the module into iOS, get this error: "Native module cannot be null".

1.) Builds fine
a. I do have an updated Bridge file
b. Followed the instructions for iOS per Google
c. Followed the instructions in the documentation for modifying my ios project
d. I verified the pod is present after running 'pod install'
e. ... No errors during build
2.) My Splash screen works
3.) And then RN is throwing the error in the module here:

{
column = 39;
file = "/{MY_APP_PATH_HIDDEN}/node_modules/react-native-google-sign-in/js/GoogleSignIn.ios.js";
lineNumber = 14;
methodName = "";
},

Always getting warning "possible unhandled promise rejection (id 0) 12501"

I am trying to work with it and after configure and run when I click on the sign in button is showing this warning and there is no output.

screenshot_1

Code i have used:

import React, { Component } from 'react';
import { Text, View, TouchableOpacity } from 'react-native';
import { StackNavigator, NavigationActions } from 'react-navigation';
import GoogleSignIn from 'react-native-google-sign-in';

export default class LoginScreen extends Component {
	constructor(props){
		super(props)
	}

	// async _signIn(){
	// 	GoogleSignin.configure({
			// scopes: [
			// 	'https://www.googleapis.com/auth/drive',
			// 	'https://www.googleapis.com/auth/drive.appdata',
			// 	'https://www.googleapis.com/auth/drive.file',
			// 	'https://www.googleapis.com/auth/drive.metadata',
			// 	'https://www.googleapis.com/auth/drive.metadata.readonly',
			// 	'https://www.googleapis.com/auth/drive.photos.readonly',
			// 	'openid',
			// 	'email',
			// 	'profile'
			// ],
			// iosClientId: '454510003783-ftcotf82ko3o37dt7gn91g2rmstsdhat.apps.googleusercontent.com', // only for iOS
			// webClientId: '454510003783-1iuf68qbrjsap6ubiekk6lfjlp62pgt1.apps.googleusercontent.com', // client ID of type WEB for your server (needed to verify user ID and offline access)
			// offlineAccess: true,
			// accountName: 'AllstarIQ' // [Android] specifies an account name on the device that should be used
	// 	})
	// 	.then(() => {
	// 		await GoogleSignin.currentUserAsync().then((user) => {
	// 			console.error('USER', user);
	// 			this.setState({user: user});
	// 		}).done();
	// 	});
	// }

	async _signIn() {
		await GoogleSignIn.configure({
			clientID: '531870286570-28gcrs4oin53rb0aoc8igkutfo2gfijr.apps.googleusercontent.com',
			scopes: [
                'https://www.googleapis.com/auth/drive',
                'https://www.googleapis.com/auth/drive.appdata',
                'https://www.googleapis.com/auth/drive.file',
                'https://www.googleapis.com/auth/drive.metadata',
                'https://www.googleapis.com/auth/drive.metadata.readonly',
                'https://www.googleapis.com/auth/drive.photos.readonly',
                'openid', 'email', 'profile'
            ],
			offlineAccess: true,
            forceCodeForRefreshToken: false
		});

		const user = await GoogleSignIn.signInPromise();
		setTimeout(() => {
			alert(JSON.stringify(user));
		}, 2000);
	}

    render() {
        return (
            <View style={{flex:1, justifyContent: 'center', alignItems: 'center'}}>
            <TouchableOpacity
                style={{width: 200, height: 68}}
				onPress={() => this._signIn()}>
				<Text>SignIn</Text>
				</TouchableOpacity>
            </View>
        )
    }
}

Is there any solution for this problem. Please help me out.

Multiple dex files define Lcom/google/firebase/iid/zzb$1;

Hello, I'm getting this error after trying to run react-native run-android.

Here is my android/app/build.gradle dependencies
dependencies { compile project(':react-native-google-sign-in') compile project(':react-native-fbsdk') compile project(':react-native-shared-preferences') compile project(':react-native-maps') compile 'com.google.android.gms:play-services-auth:10.0.1' compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules }

Is this working with Android API 19?

I almost did everything, and i cant find solutions to my problem. I am testing and building my application on android api 19. It doesn't open after building it, after adding react native google sign in and i've done all of the steps. This is my build.gradle:

dependencies {
compile 'com.android.support:multidex:1.0.1'
compile(project(":react-native-google-sign-in")) { // ADD this
exclude group: "com.google.android.gms"
}
compile(project(':react-native-firebase')) {
transitive = false
}
compile project(':react-native-fbsdk')
compile project(':react-native-vector-icons')
compile(project(':react-native-maps')){
exclude group: 'com.google.android.gms'
}
compile project(':react-native-geocoder')
compile fileTree(include: ['*.jar'], dir: 'libs')
// From node_modules
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.facebook.react:react-native:+'
compile ("com.google.android.gms:play-services-base:11.0.4") {
force = true;
}
compile ("com.google.android.gms:play-services-maps:11.0.4") {
force = true;
}
compile ("com.google.firebase:firebase-core:11.0.4") {
force = true;
}
compile ("com.google.firebase:firebase-auth:11.0.4") {
force = true;
}
}

apply plugin: 'com.google.gms.google-services'

While this is my android/build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath 'com.google.gms:google-services:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

Please help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.