Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 29, 2021 09:06 am GMT

Anayo Debugging 1: java.lang.NoClassDefFoundError: failed for class com.facebook.flipper.android.EventBase

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 = }
/? E/studio.deploy: Could not get package user id: run-as: unknown package: com....
/? E/studio.deploy: Could not find apks for this package: com....
/? E/Finsky: [2] VerifyPerSourceInstallationConsentInstallTask.d(2): Package name null is not an installed package
/? E/installd: Couldn't opendir /data/app/vmdl1184715882.tmp: No such file or directory
/? E/installd: Failed to delete /data/app/vmdl1184715882.tmp: No such file or directory
/? E/ssioncontrolle: Not starting debugger since process cannot load the jdwp agent.
java.lang.NoClassDefFoundError: <clinit> failed for class com.facebook.flipper.android.EventBase; see exception in other thread

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

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
  • 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: [email protected]

Cheers and take care.


Original Link: https://dev.to/anayooleru/anayo-debugging-1-javalangnoclassdeffounderror-failed-for-class-comfacebookflipperandroideventbase-3pm5

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To