NoClassDefFoundError despite using api for dependency in a library

13 Views Asked by At

Android library foolib has the following in in its build.gradle:

api('com.github.hedzr:android-file-chooser:v1.2.0-final')

The library generates its aar file foolib.aar. App MyApp uses foolib.aar. foolib has many functions and all of them work fine except the file chooser. When MyApp uses a library function that uses the file chooser, it throws the following exception:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/obsez/android/lib/filechooser/ChooserDialog

I thought api makes the dependency transitive and the MyApp would get the library. If I use the following in MyApp's build.grale, everything will be fine:

implementation 'com.github.hedzr:android-file-chooser:v1.2.0-final'

Could anyone shed some light on this? I am asking this to help me understand api.

0

There are 0 best solutions below