java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/content/ContextCompat; - U

When I try to export my project Android build, I am getting this kind of error in debug log and my game get force closed on the spot.

Let me explain what I have done so I have started getting this error. Newly I have implemented AdMob Mediation within my game project.

So I have integrated Chartboost Mediation plugin within my project and from first to last I have followed this document:

Additionally, I have added Chartboost.jar and android-support-v4.jar files within my Plugins/Android folder.

After doing these steps my project started crashing on start and before it was working fine because I have a backup of the previous version of my Unity project.

Here you have my project Build settings image:

Now I want to solve this problem so please guide some solution for this. I am available for all kinds of experiments.

Confirm, have multiple crashes with AdMob Mediation and com.moat.analytics crashes. We also use Chartboost and some other mediation plugins. I’ve contacted with AdMob team, they told me they don’t have anything related to Moat Analytics in their codes, so they won’t care about it.

1 Like

I hope someone will share their opinion on this subject.

So, same issue here, but I have a lot of plugins integrated and it all works fine(IronSource, Amplitude, Google Play Games, some other native plugins) but when I added EasyMobile Pro plugin, it’s start crashing with the same Issue. So, is there any solutions?

So, I’m fixed this problem, for more info check this AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/content/LocalBroadcastManager · Issue #402 · firebase/quickstart-unity · GitHub

First of all, I found and install PlayServicesResolver 1.2.95 and it don’t download androidx libraries - it is what we need.
Secondly, run force resolve to download old androd libraries.

You should check that you plugins folder don’t contain any androidx libs, and use only android libs to avoid any errors. Also waiting for normal support for androidx. Good luck)

@siddharth3322 Did you find any solution for this issue?

No, I can’t able to solve this problem so I have removed the Chartboost ad network from my project and integrated other ad networks within my Admob Mediation setup.

Because only Chartboost giving me this kind of problems.

1 Like

Solved. If you have a crash in Chartboost Unity with AndroidX and have an error “android.support.v4.content.ContextCompat”:
The problem is that current chartboost library from sdk not “jetified”.
“The standalone Jetifier tool migrates support-library-dependent libraries to rely on the equivalent AndroidX packages instead.”

1). Download jetifier

2). After you integrate Chartboost to unity project, select “chartboost.jar” from Assets\Plugins\Android\ChartboostSDK\libs\chartboost.jar
rename it to “chartboostX.jar” and use command:

./jetifier-standalone -i chartboostX.jar -o chartboost.jar

Replace with new “chartboost.jar” in Unity project.

3). Don’t forget to add

([rootProject] + (rootProject.subprojects as List)).each {
    ext {
        it.setProperty("android.useAndroidX", true)
        it.setProperty("android.enableJetifier", true)
    }
}

to your gradle file.
And also add only in dependencies section:

implementation 'androidx.appcompat:appcompat:1.1.0'

and remove:

implementation 'com.android.support:support-v4:27.1.1'

(I think: because you need to use only androidX libraries, for example by convert all the support libraries to androidX).

4). Profit!

4 Likes