Home » Java » Class not included in the aar

Class not included in the aar

Posted by: admin December 28, 2021 Leave a comment

Questions:

I’m using Android Studio 1.0.1.

I managed to configure Android Library module in a project, so it’s built into AAR.

My problem is that the AAR archive does not have my class inside. When I check MyProject/MyModule/build/intermediates/classes/debug/my/package/mymodule I can see my class compiled: MyClass.class

But when I enter to AAR (or unpack it), the very same directory (I mean the my/package/mymodule in classes.jar inside of the AAR file) contains only one file: BuildConfig.class

Why isn’t my class included in the AAR?

Answers:

maybe it has to do with the proguard configuration i had the same problem, i resolved it by adding a rule in the proguard-rules file. here is exactly what i did:

  • adding rule -keep public class my.package.** { public *;} proguard-rules.pro file
  • run gradlew assemble on terminal

after that you will find your aar file in youModule/build/outputs/aar/ directory

Hope this help

###

I was messing around with plugins and in my case (a Kotlin library) I removed by accident too many of them. If your *.aar is empty too, make sure you’ve got at lease these two set:

plugins {
    id("com.android.library")
    id("kotlin-android") // <-- this one was missing
}