android – Desugaring of a Fragment inside a library is failing-ThrowExceptions

Exception or error:

I have a fragment VideoPlayerBaseFragment inside a library project.
I am using this library inside my app using artifactory build
implementation

"com.mindvalley.module_videoplayer:module_videoplayer:1.9.3.6"

When I am building my app it is throwing following error :

Default method desugaring of
com.mindvalley.module_videoplayer.base.fragment.VideoPlayerBaseFragment
failed because its super class androidx.fragment.app.Fragment is
missing

My library module implements exoplayer library

api “com.google.android.exoplayer:exoplayer:2.10.5”

I am unable to find the reason for this. It works fine with other libraries I have created and they also have fragment in them.

How to solve:

I also encountered this issue. The solution in my case turned out to be rather simple. I had to disable desugaring with D8 in my project’s gradle.properties file. This can be done with the 2 lines below:

android.enableD8=false
android.enableD8.desugaring=false

You can then sync the project files, clean your project and build a debug apk. I encountered this issue when trying to build a debug apk or run instrumentation tests on an emulator running API 16, I never had when building release apk.

Leave a Reply

Your email address will not be published. Required fields are marked *