It's late on Friday before a long weekend, and I'm having issues running an react-native app. Current version is 0.60 (latest), and running the command
react-native run-android
Results in a debug build that successfully installs on my connected app, but crashes upon opening with the following error:
FATAL EXCEPTION: main
Process: com.myApp, PID: XXXX
java.lang.NoClassDefFoundError: Failed resolution of:
Lcom/google/android/gms/common/internal/zzbq
Googling this cryptic error results in a number of results suggesting MultiDex to be the culprit, and how to handle this. I'll link some threads for research's sake:
Android 3.1.1 - Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;
Didn't find class "com.google.android.gms.common.internal.zzbq" on path: DexPathList
(links to previous result)
One of the solutions, namely overriding use version for com.google.android.gms if name contains multidex to version 12.0.1 works for debug builds:
In android/build.gradle:
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.google.android.gms'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "12.0.1"
}
}
}
}
However, this causes completely different issues for production builds:
Could not find com.google.android.gms:play-services-vision-image-label:12.0.1.
Could not find com.google.android.gms:play-services-clearcut:12.0.1
Could not find com.google.android.gms:play-services-phenotype:12.0.1
Could not find com.google.android.gms:play-services-stats:12.0.1
All of these are saying "Required by XXX:17.0.1", so I tried details.useVersion "17.0.1", but that resulted in a similar issue:
Could not find com.google.android.gms:play-services-location:17.0.1
Could not find com.google.android.gms:play-services-base:17.0.1
Could not find com.google.android.gms:play-services-basement:17.0.1
Could not find com.google.android.gms:play-services-tasks:17.0.1
Some of these modules have version 17.0.1, while others are at 17.0.2 or 17.0.0, so a strict use version X.Y.Z will not work for release build.
If I remove this subProjects { ... } declaration and attempt to enable MultiDex as suggested in other answers:
In android/app/build.gradle:
android {
defaultConfig {
...
multiDexEnabled true
}
}
dependencies {
...
implementation 'com.android.support:multidex:1.0.3'
}
This results in the same error for both debug and release builds, and a little bit of extra Googling uncovers that MultiDex is not required for SDK version > 27.0.0 (looks to be using 28.0.0 / 28.0.3)
I've been banging my head against this for the entire day and haven't been able to make any progress. Has anyone seen this issue as it pertains to React Native 0.60?
Note: There are a couple plugins that are using these com.google.android.gms in my project, namely:
react-native-background-geolocationimplementation "com.google.android.gms:play-services-location:$playServicesLocationVersion"
react-native-camerageneralImplementation "com.google.android.gms:play-services-vision:$googlePlayServicesVisionVersion"
react-native-device-infoimplementation "com.google.android.gms:play-services-gcm:${safeExtGet('googlePlayServicesVersion', '16.1.0')}"