question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzw

See original GitHub issue

Hi,

I updated my dependencies in my app/build.gradle. Now I get the following red-screen error when I start my app (everything else is building correctly):

Java exception in 'NativeModules'

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/util/zzw;
com.learnium.RNDeviceInfo.RNDeviceModule.getConstants
    RNDeviceModule.java:260
com.facebook.react.bridge.JavaModuleWrapper.getConstants
    JavaModuleWrapper.java:140
android.os.Handler.handleCallback
    Handler.java:751
android.os.Handler.dispatchMessage
    Handler.java:95
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
    MessageQueueThreadHandler.java:31
<unknown>
    deviceinfo.js:6:33
loadModuleImplementation
    require.js:213:12
guardedLoadModule
    require.js:147:36
_require
    require.js:131:20
<unknown>
    HotelsScreen.js:19
loadModuleImplementation
    require.js:213:12
guardedLoadModule
    require.js:147:36
_require
    require.js:131:20
<unknown>
    StartScreen.js:5
loadModuleImplementation
    require.js:213:12
guardedLoadModule
    require.js:147:36
_require
    require.js:131:20
<unknown>
    AppNavigator.js:13
loadModuleImplementation
    require.js:213:12
guardedLoadModule
    require.js:147:36
_require
    require.js:131:20
<unknown>
    Root.js:4
loadModuleImplementation
    require.js:213:12
guardedLoadModule
    require.js:147:36
_require
    require.js:131:20
<unknown>
    index.android.js:3
loadModuleImplementation
    require.js:213:12
guardedLoadModule
    require.js:140:45
_require
    require.js:131:20
global code
    

This only happens on android. I tried to add

compile ("com.google.android.gms:play-services-gcm:16.1.0") {
            force = true;
        }

in my dependencies, but with no luck.

my android settings:

compileSdkVersion 27 buildToolsVersion “27.0.1” … minSdkVersion 16 targetSdkVersion 27 Device: Samsung Galaxy S6

also, I tried to do the following suggestions: https://stackoverflow.com/questions/51036749/react-native-device-info-crash-the-app-on-android but that didn’t work either.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

3reactions
dwidccommented, Aug 15, 2018

I also got the same problem recently. After hours of trials and errors (and hair pulling), turned out it’s simply because of version mismatch between 'play-services-gcm' and 'firebase-messaging'.

I have "com.google.android.gms:play-services-gcm:10.2.6" set on app/build.gradle dependencies. But I never set or include 'firebase-messaging', it’s probably included implicitly by one of library.

To force versions used by library, you can set it on app/build.gradle:

configurations.all {
    resolutionStrategy {  
        // ...
        force 'com.google.android.gms:play-services-gcm:10.2.6'
        force 'com.google.firebase:firebase-messaging:10.2.6'
    }
}

or

dependencies {
    // ...
    compile ('com.google.android.gms:play-services-gcm:10.2.6') {
        force = true;
    }
    compile ('com.google.firebase:firebase-messaging:10.2.6') {
        force = true;
    }
}

either one will give the same result, I prefer the first one because it’s easy on eyes.

That’s it, it fixes the dreaded red screen NoClassDefFoundError for me.


You might want to verify versions used by library dependencies.

To see actual versions used by dependencies, check your '\android\app\build\intermediates\exploded-aar\' folder.

For example in my pc I have: \exploded-aar\com.google.android.gms\play-services-gcm\10.2.6\ and \exploded-aar\com.google.firebase\firebase-messaging\10.2.6\ folder, which is good because both versions are the same.

Make sure libraries inside \com.google.android.gms\ and \com.google.firebase\ all use the same version.


If all above still fails, as last resort you can try disable InstanceID check on RNDeviceModule.java.

https://github.com/rebeccahughes/react-native-device-info/blob/02d63b9aabf7f553abe77bb72bc024f35ef1db68/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java#L270-L276

You can find it on your local \node_modules\react-native-device-info\android\src\main\java\com\learnium\RNDeviceInfo\RNDeviceModule.java

That InstanceID.getInstance().getId() line is where you get the red screen runtime error of NoClassDefFoundError.

I try commenting it out at first, and it works preventing NoClassDefFoundError. But it’s a quick hack, it doesn’t solve the main problem. Only use it if you’re in a hurry. 😉

Hope this helps.

3reactions
x0fmacommented, Aug 6, 2018

Hey I had the same problem, I’ve resolved it by adding googlePlayServicesVersion=X.X.X in the gradle.properties file in the android folder. Tell me if it works for you ^^

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed resolution of: Landroid/support/v4/os/BuildCompat ...
You are getting NoClassDefFoundError & ClassNotFoundException. NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular ...
Read more >
java.lang.NoClassDefFoundError: Failed resolution of: Lcs ...
i compiled my extension but java.lang.NoClassDefFoundError: Failed resolution of: Lcs/min2phase/Search; is the error i got in app ...
Read more >
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin ...
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/KotlinPackage. Try to run a Kotlin project on Android studio (3.6.+) then get this error and ...
Read more >
java.lang.NoClassDefFoundError: Failed resolution of - Medium
NoClassDefFoundError : Failed resolution of: Lcom/package/id/MyLayoutBinding. Sometime back we upgraded our android project gradle wrapper ...
Read more >
java.lang.NoClassDefFoundError: Failed resolution of: Lcom ...
When using compile 'net.rdrei.android.dirchooser:library:3.2@aar', I get the following error: 04-09 22:50:20.638 11862 11862 E ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found