react-native-google-signin / google-signin

Google Sign-in for your React Native applications
https://react-native-google-signin.github.io/
MIT License
3.19k stars 877 forks source link

React Native Google Signin not working in Android DEBUG build #685

Closed dsgithub2018 closed 5 years ago

dsgithub2018 commented 5 years ago

I am not able to make android DEBUG build after setting up react-native-google-signin whereas RELEASE build is working fine. I have followed all the instruction given in "https://github.com/react-native-community/react-native-google-signin". I am getting the following error on each successful DEBUG build, "RN GoogleSignin native module is not correctly linked. Please read the readme, setup and troubleshooting instructions carefully or try manual linking". So can anybody give me the steps to setup it in DEBUG build so that I can develop the entire thing in debug build. Here are my system information,

OS: Ubuntu

In package.json: "native-base": "^2.12.1", "react": "16.3.1", "react-native": "0.55.3", "react-native-google-signin": "^2.0.0"

In android/build.gradle: def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback }

buildscript { ext { buildToolsVersion = "28.0.3" minSdkVersion = 19 compileSdkVersion = 28 targetSdkVersion = 28 supportLibVersion = "26.0.1" googlePlayServicesAuthVersion = "16.0.1" // <--- use this version or newer } repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.1.4' classpath 'com.google.gms:google-services:4.2.0'

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

}

allprojects { repositories { google() mavenLocal() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com/' name 'Google' } } }

subprojects { if (project.name.contains('react-native-image-picker')) { buildscript { repositories { jcenter() maven { url "https://dl.bintray.com/android/android-tools/" } } } } }

subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "26.1.0" } } } }

In android/app/build.gradle: apply plugin: "com.android.application" import com.android.build.OutputFile

project.ext.react = [ entryFile: "index.js" ]

apply from: "../../node_modules/react-native/react.gradle" def enableSeparateBuildPerCPUArchitecture = false def enableProguardInReleaseBuilds = false

android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
    applicationId "**********************************"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 2
    versionName "4.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }

    multiDexEnabled true
}
signingConfigs {
    release {           
        storeFile file(MYAPP_RELEASE_STORE_FILE)
        storePassword MYAPP_RELEASE_STORE_PASSWORD
        keyAlias MYAPP_RELEASE_KEY_ALIAS
        keyPassword MYAPP_RELEASE_KEY_PASSWORD            
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}
buildTypes {
   release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}

lintOptions {
    abortOnError false
}

}

dependencies { implementation project(':react-native-google-signin') implementation project(':react-native-text-input-mask') implementation project(':react-native-image-picker') implementation project(':react-native-device-info') implementation project(':react-native-pdf') implementation project(':rn-fetch-blob') implementation project(':react-native-fbsdk') implementation project(':react-native-calendar-events') implementation fileTree(dir: "libs", include: ["*.jar"]) implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}" implementation "com.google.android.gms:play-services-auth:${safeExtGet('googlePlayServicesAuthVersion', '16.0.1')}" implementation "com.facebook.react:react-native:+" // From node_modules

//compile 'com.google.android.gms:play-services-auth:16.0.1'

implementation "com.facebook.android:facebook-android-sdk:4.34.0"
implementation project(':react-native-fbsdk')

implementation 'com.google.firebase:firebase-core:16.0.9'

}

// 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'

In android/app/src/main/java/com/{app-name}/MainApplication.java: package **; import android.app.Application; import com.facebook.react.ReactApplication; import co.apptailor.googlesignin.RNGoogleSigninPackage; import com.RNTextInputMask.RNTextInputMaskPackage; import com.imagepicker.ImagePickerPackage; import com.learnium.RNDeviceInfo.RNDeviceInfo; import org.wonday.pdf.RCTPdfView; import com.RNFetchBlob.RNFetchBlobPackage; import com.facebook.reactnative.androidsdk.FBSDKPackage; import com.calendarevents.CalendarEventsPackage; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import com.facebook.soloader.SoLoader; import com.facebook.CallbackManager; import com.facebook.FacebookSdk; import com.facebook.reactnative.androidsdk.FBSDKPackage; import com.facebook.appevents.AppEventsLogger; import java.util.Arrays; import java.util.List;

public class MainApplication extends Application implements ReactApplication {

private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

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

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
      new RNGoogleSigninPackage(),
      new RNTextInputMaskPackage(),
      new ImagePickerPackage(),
      new RNDeviceInfo(),
      new RCTPdfView(),
      new RNFetchBlobPackage(),
      new FBSDKPackage(mCallbackManager),
      new CalendarEventsPackage()
  );
}

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

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

@Override public void onCreate() { super.onCreate(); SoLoader.init(this, / native exopackage / false); FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); } }

In android/setting.gradle: rootProject.name = '****' include ':react-native-google-signin' project(':react-native-google-signin').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-signin/android') include ':react-native-text-input-mask' project(':react-native-text-input-mask').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-text-input-mask/android') include ':react-native-image-picker' project(':react-native-image-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-picker/android') include ':react-native-device-info' project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android') include ':react-native-pdf' project(':react-native-pdf').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pdf/android') include ':rn-fetch-blob' project(':rn-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/rn-fetch-blob/android') include ':react-native-fbsdk' project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android') include ':react-native-calendar-events' project(':react-native-calendar-events').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-calendar-events/android') include ':react-native-navigation' project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')

include ':app'

In Firebase console: I have successfully created and verified the app in Firebase by adding all debug/release keystore fingerprints. And also downloaded the google-services.json and placed it in android/app.

vonovak commented 5 years ago

hello and thanks for reporting

"RN GoogleSignin native module is not correctly linked. Please read the readme, setup and troubleshooting instructions carefully or try manual linking".

So can anybody give me the steps to setup it in DEBUG build so that I can develop the entire thing in debug build.

the instructions are here: https://github.com/react-native-community/react-native-google-signin/blob/master/docs/ios-guide.md hope this helps.

carloslibardo commented 4 years ago

@vonovak i'm having the same issue, also in android, why ios config should be related with android crash?

vonovak commented 4 years ago

@kaduelinho sorry, I meant this https://github.com/react-native-community/react-native-google-signin/blob/master/docs/android-guide.md

carloslibardo commented 4 years ago

@vonovak, same as i post in the other issue: https://github.com/react-native-community/react-native-google-signin/issues/771

My Environment is

RN^0.61.2 @react-native-community/google-signin@3.0.3

I link with react-native link @react-native-community/google-signin command and works right, it's not the perfect solution, because should be right with autolinking, but now i can open my app without crash.

And i follow the installation guide steps, this issue shouldn't be closed, in my opinion.

vonovak commented 4 years ago

@kaduelinho as explained in the issue template, we require issues to have a runnable repro. Please add a runnable repro, and I'll reopen. Thanks.

scruntlabs commented 4 years ago

@vonovak I may not be 100% right but this issue seems to be occurring in mac machines. I have the same config in Linux it works fine. I also did a pod install in ios directory.