java.lang.NoClassDefFoundError: <clinit> failed for class com.facebook.flipper.android.EventBase
Tags: reactnative, androidstudio, flipper, unknownpackage
Published: 2021-12-29 09:06:11

---
title: java.lang.NoClassDefFoundError: <clinit> failed for class com.facebook.flipper.android.EventBase
published: true
description: 
tags: reactnative, Androidstudio, flipper, unknownpackage
cover_image: https://res.cloudinary.com/dvfr0z8wr/image/upload/v1618982580/YouPractice/yecdeq7qa3lqfwcuzpke.jpg
---

_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 = }
```

```

/? 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](https://twitter.com/AnayoOleru) or send an email to: anayo_oleru@outlook.com

Cheers and take care.