Search code examples
androidgradlepluginsaar

Build AAR with dependencies


I want to build .AAR with dependencies inside. I was looking for a lot but nothing works. Topics are so old. I realized that resultant .AAR should have classes.jar inside and there are directories with .class files. But I don't know how to automatize this process in gradle.


Solution

  • We manage to do this using this Mobbeel fat AAR Gradle plugin: https://github.com/Mobbeel/fataar-gradle-plugin

        buildscript {
            repositories {
                //...
                maven {
                    url 'https://plugins.gradle.org/m2/'
                }
            }
        }
    
        //...
    
        dependencies {
            classpath 'gradle.plugin.com.mobbeel.plugin:mobbeel-fataar:1.2.0'
        }
    

    Mark dependencies with api instead of implementation

        apply plugin: 'com.mobbeel.plugin'
    
        dependencies {
            api 'org.greenrobot:eventbus:3.0.0'
            //...
        }
    
        fatAARConfig {
            includeAllInnerDependencies false
        }
    

    This article was helpful: http://wittchen.io/2018/10/02/creating-fat-aar/