DEV Community

Cover image for java.lang.NoClassDefFoundError: <clinit> failed for class com.facebook.flipper.android.EventBase
Anayo Samson Oleru
Anayo Samson Oleru

Posted on • Updated on

java.lang.NoClassDefFoundError: <clinit> failed for class com.facebook.flipper.android.EventBase

Anayo Debugging 1

Bug

Generating an Android build package(APK)from Android Studio builds successfully. But running the generated APK on a real device or device connected to Android Studio Crashes on launch and returns the following errors.

getWifiLinkLayerStats_1_3_Internal(l.973) failed {.code = ERROR_NOT_SUPPORTED, .description = }
Enter fullscreen mode Exit fullscreen mode

/? E/studio.deploy: Could not get package user id: run-as: unknown package: com....
Enter fullscreen mode Exit fullscreen mode

/? E/studio.deploy: Could not find apks for this package: com....
Enter fullscreen mode Exit fullscreen mode

/? E/Finsky: [2] VerifyPerSourceInstallationConsentInstallTask.d(2): Package name null is not an installed package
Enter fullscreen mode Exit fullscreen mode

/? E/installd: Couldn't opendir /data/app/vmdl1184715882.tmp: No such file or directory
Enter fullscreen mode Exit fullscreen mode

/? E/installd: Failed to delete /data/app/vmdl1184715882.tmp: No such file or directory
Enter fullscreen mode Exit fullscreen mode

/? E/ssioncontrolle: Not starting debugger since process cannot load the jdwp agent.
Enter fullscreen mode Exit fullscreen mode

java.lang.NoClassDefFoundError: <clinit> failed for class com.facebook.flipper.android.EventBase; see exception in other thread
Enter fullscreen mode Exit fullscreen mode

I read through all, trying to understand each of them. But what stood out from these errors, and that has some sort of clarity is the last one:

java.lang.NoClassDefFoundError: <clinit> failed for class com.facebook.flipper.android.EventBase; see exception in other thread
Enter fullscreen mode Exit fullscreen mode

I was a bit skeptical, because it's getting really difficult to justify Flipper, a debug tool shouldn't crash and block the development process.

How I solved it

After several trial and error, I was able to arrive at a solution that worked. I had to re-think, this particular error happens when after I try running the generated APK and not when I was generating a build. And I looked at how the Android build process works, the compiler converts the source code into DEX(whatever the name is) files, which include byte code that runs on android devices. So this would mean that while compiling, there was possibly a mix of old and new source code(which is possible since there is no such thing as a perfect compiler), or if there isn't no issue, then there must be something wrong with the compiled files.

What is the best way to resolve something like this? As any other way, deleting the build and starting afresh as a new build.

This is what I did, and it worked.

Here is what I did, the steps I took:

  • Deleted android build file, you can find this file in: android>app inside app delete build folder
  • Then I cleaned the gradlew:
cd android &&./gradlew clean
Enter fullscreen mode Exit fullscreen mode
  • Next I rebuilt the application again
  • Then I ran the APK

Voila! It solved all the above issues. I hope this will help you and save you time, if you face similar error or the same error.

If it helps you, like this post.


My name is Anayo Oleru, I specialise in Backend Development(NodeJS & ExpressJS), but I am experienced with Web frontend(ReactJS) and mobile(React-native). And I am open to offers in these fields.

You can follow me on Twitter at @AnayoOleru or send an email to: anayo_oleru@outlook.com

Cheers and take care.

Latest comments (0)