Hi,
I was working on a project and wanted to add Google Signin to it..,App was working fine before but after doing all the steps to set up this library and after runnig 'react-native run-android' via CLI..., it built successfully with no errors and even loaded bundles successfully but immediately crashed on launching. Searched everywhere but couldn't find the solution.
I checked the logs via 'react-native log-android' but failed to figure out anything from it:
LOGS:
Starting the logger (D:\Android/platform-tools/adb logcat *:S ReactNative:V ReactNativeJS:V)...
--------- beginning of system
--------- beginning of crash
--------- beginning of main
08-22 05:28:57.233 26056 26056 D ReactNative: ReactInstanceManager.ctor()
08-22 05:28:57.273 26056 26056 D ReactNative: ReactInstanceManager.createReactContextInBackground()
08-22 05:28:57.273 26056 26056 D ReactNative: ReactInstanceManager.recreateReact
ContextInBackgroundInner()
08-22 05:28:58.303 26056 26056 D ReactNative: ReactInstanceManager.recreateReact
ContextInBackgroundFromBundleLoader()
08-22 05:28:58.303 26056 26056 D ReactNative: ReactInstanceManager.recreateReact
ContextInBackground()
08-22 05:28:58.304 26056 26056 D ReactNative: ReactInstanceManager.runCreateReac
tContextOnNewThread()
08-22 05:28:58.346 26056 26098 D ReactNative: ReactInstanceManager.createReactCo
ntext()
While setting up this library i had to upgrade my Android SDK build version to 27.0.3 and gradle to 4.4
```
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.bzyness"
minSdkVersion 19
targetSdkVersion 25
renderscriptSupportModeEnabled true
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
and supportLibVersion = "26.1.0"
**Dependencies:**
dependencies {
implementation(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.facebook.react:react-native:+"
compile project(':react-native-fbsdk')
compile project(':react-native-image-resizer')
compile project(':react-native-image-picker')
compile project(':react-native-fs')
compile project(':react-native-vector-icons')
compile(project(':react-native-maps')){
exclude group: 'com.google.android.gms'
}
implementation 'com.google.android.gms:play-services-auth:15.0.0'
}
```
-Device
Genymotion Custom phone 6.0 Api 23
Thanks in advance for any type of help :smile:
I've not tried Gradle 4.4 but I've used 3.1.2. Also try to clean cache by running ./gradlew clean in android directory.
In your configuration you've got compile keyword. I think it's deprecated in newer gradle versions so just replacing them with implementation should work.
Could you paste your build log when you run react-native run-android?
@jozan thanks for replying,
Tried ./gradlew clean and removing compile with implementation but still the same.
After some research found out that crash is because of intermixing of support versions of different libraries installed and not because of any bug here.
Haven't solved the issue yet but hope to find something.
Thanks
Has your problem been resolved?
@Rish02Sharma Hey, I am also facing the same issue. Have you spotted any solution?
No, have even tried to setup every other libraries manually on a new React native project...still after setting up Google signin..there is no change....App still crashes after successful build.
@Rish02Sharma I have same issue !
@Rish02Sharma Use react-native-google-sign-in instead. There is sample project and it worked like a charm!!!!! :)))
Has anyone found solution to this
@rahuluvionics I have implemented both of these google signin libraries and both works fine individually....the project which I was working on before contains 10-15 other libraries too...I think newer versions of react native can handle this coz I have tried implementing react-native-google-signin independently and haven't faced any issues.
I've react native .59.6 . Below is my google sign in function it crashes at await GoogleSignin.signIn();
I'm using React Native navigation with which it was clashing for getconstant function.Have already resolved that
googleSignIn = async () => {
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
this.setState({ userInfo });
} catch (error) {
console.log(error.code);
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
// user cancelled the login flow
} else if (error.code === statusCodes.IN_PROGRESS) {
// operation (f.e. sign in) is in progress already
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
// play services not available or outdated
} else {
// some other error happened
}
}
}
hi everyone, I can run this code:
android\build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesAuthVersion = "15.0.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:3.2.1'
// 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"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.10.1'
distributionUrl = distributionUrl.replace("bin", "all")
}
android\app\build.gradle
Dependencies:
dependencies {
compile project(':react-native-google-signin')
compile project(':react-native-orientation')
compile project(':react-native-device-info')
compile project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-core:15.0.0'
}
android\gradle\wrapper\gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
package.json
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.4",
"react-native-google-signin": "^2.0.0",
In mysetup
Studio logs was
AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.myapp, PID: 20976
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/swiperefreshlayout/widget/SwipeRefreshLayout;
I added following lines to dependencies section in android/app/build.gradle
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
Doing so my app is not crashing now
Most helpful comment
@jozan thanks for replying,
Tried
./gradlew cleanand removingcompilewithimplementationbut still the same.After some research found out that crash is because of intermixing of
support versionsof different libraries installed and not because of any bug here.Haven't solved the issue yet but hope to find something.
Thanks