Google-signin: E/ReactNativeJS: undefined is not an object (evaluating 'RNGoogleSignin.BUTTON_SIZE_ICON') android project

Created on 25 Aug 2017  路  16Comments  路  Source: react-native-google-signin/google-signin

React Native version: react-native:0.47.1,
react-native-google-signin version: ^0.11.0

I've linked and installed react-native-google-signin,
and fulfilled step by step the android guide

Yet I still get the error:

E/ReactNativeJS: undefined is not an object (evaluating 'RNGoogleSignin.BUTTON_SIZE_ICON')

This error was issued earlier, yet there is no reliable solution found.
I've tried to reinstall and relink the module as was proposed yet with no success.

The issue occurs at import stage:

import {GoogleSignin, GoogleSigninButton} from "react-native-google-signin";

Here is my gradle dependencies:
```
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.facebook.react:react-native:0.47.1'
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
compile ('com.google.android.gms:play-services-auth:11.0.4') {
force = true;
}
compile ('com.google.android.gms:play-services-analytics:11.0.4'){
force = true;
}
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply plugin: 'com.google.gms.google-services' // <--- this should be the last line

`

```
Here is my android App class:

public class App extends Application implements ReactApplication {


@Override
public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
}

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
        return BuildConfig.DEBUG;
    }

    /**
     * A list of packages used by the app. If the app uses additional views
     * or modules besides the default ones, add more packages here.
     */
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
                new MainReactPackage(),
                new RNGoogleSigninPackage()
        );
    }
};

}

And here is the full output:

undefined is not an object (evaluating 'RNGoogleSignin.BUTTON_SIZE_ICON') <unknown> index.android.bundle?platform=android&dev=true&hot=false&minify=false:96847:23 loadModuleImplementation index.android.bundle?platform=android&dev=true&hot=false&minify=false:106:12 guardedLoadModule index.android.bundle?platform=android&dev=true&hot=false&minify=false:70:36 _require index.android.bundle?platform=android&dev=true&hot=false&minify=false:54:77 <unknown> index.android.bundle?platform=android&dev=true&hot=false&minify=false:96779:116 loadModuleImplementation index.android.bundle?platform=android&dev=true&hot=false&minify=false:106:12 guardedLoadModule index.android.bundle?platform=android&dev=true&hot=false&minify=false:70:36 _require index.android.bundle?platform=android&dev=true&hot=false&minify=false:54:77 <unknown> index.android.bundle?platform=android&dev=true&hot=false&minify=false:59371:39 loadModuleImplementation index.android.bundle?platform=android&dev=true&hot=false&minify=false:106:12 guardedLoadModule index.android.bundle?platform=android&dev=true&hot=false&minify=false:70:36 _require index.android.bundle?platform=android&dev=true&hot=false&minify=false:54:77 <unknown> index.android.bundle?platform=android&dev=true&hot=false&minify=false:52458:22 loadModuleImplementation index.android.bundle?platform=android&dev=true&hot=false&minify=false:106:12 guardedLoadModule index.android.bundle?platform=android&dev=true&hot=false&minify=false:70:36 _require index.android.bundle?platform=android&dev=true&hot=false&minify=false:54:77 <unknown> index.android.bundle?platform=android&dev=true&hot=false&minify=false:1237:22 loadModuleImplementation index.android.bundle?platform=android&dev=true&hot=false&minify=false:106:12 guardedLoadModule index.android.bundle?platform=android&dev=true&hot=false&minify=false:63:45 _require index.android.bundle?platform=android&dev=true&hot=false&minify=false:54:77 global code index.android.bundle?platform=android&dev=true&hot=false&minify=false:97102:9

What can be done about it?

馃挜 Build Issue

Most helpful comment

Upgrading to react-native 0.48 doesn't make any difference to me. Still results in the same error.

All 16 comments

same here! :(

Having the exact same issue, and have tried with versions 0.11 and 0.12

Same, with ios

++

Are you try to comment the below line?

android/app/build.gradle
// apply plugin: 'com.google.gms.google-services'

@diegomelo182 Commenting that line doesn't have any effect on this error (just tested it there).

@vanhoutk try watch this video, works for me:

https://www.youtube.com/watch?v=sT3hcMsRF68&t=1s

Was same issue - solved with upgrade of react native to
"react-native": "0.48",
If it won't help - try to install package "react-native-google-signin": "^0.12.0",

Upgrading to react-native 0.48 doesn't make any difference to me. Still results in the same error.

same here, undefined.

I am having the same problem.

Please note that I have followed the "automatic" part of the iOS guide with cocoapods.

It's working in Android though.

For iOS, it's worked for me:

  • remove reference of GoogleSdk from the project
  • copy "GoogleSdk" directory from the library to [PROJECT_ROOT]/ios
  • add "GoogleSdk" directory by drag and drop to Xcode project
  • go to "Linked Frameworks and Libraries" in Xcode click on "+" and add all frameworks from "GoogleSdk" directory

I am having the same problem in Android.
Got this error.
screen shot 2018-05-18 at 12 42 27 pm

@jaschaio how did you get it work for Android?

This is a problem with linking the library. Please check out our example App.

If the problem persist open a new issue with a reproducible example.

Thank you.

Hi Everybody I was having the same issue which just got resolved.
My react-native version is 0.50.4
react-natve-google-sign-in version is 0.12.0
I followed this link only automatic linking not mannual
https://github.com/react-native-community/react-native-google-signin/blob/master/ios-guide.md
and one more change in
node_modules/react-native-google-signin/src/
replace the below constants

GoogleSigninButton.Size = {
Icon: RNGoogleSignin.BUTTON_SIZE_ICON,
Standard: RNGoogleSignin.BUTTON_SIZE_STANDARD,
Wide: RNGoogleSignin.BUTTON_SIZE_WIDE
};
GoogleSigninButton.Color = {
Auto: RNGoogleSignin.BUTTON_COLOR_AUTO,
Light: RNGoogleSignin.BUTTON_COLOR_LIGHT,
Dark: RNGoogleSignin.BUTTON_COLOR_DARK
};

with

GoogleSigninButton.Size = {
Icon: '48 x 48',
Standard: '230 x 48',
Wide: '312 x 48'
};

GoogleSigninButton.Color = {
Auto: 'white',
Light: 'blue',
Dark: 'grey'
};

Was this page helpful?
0 / 5 - 0 ratings