I am trying to create an AAR file for a library Android project using Android Studio and gradle.
I want to exclude from this archive specific folders and files but I cannot find a working solution.
The project has 2 flavours.
app/
|--libs/
|--src/
|--flavour1/
| |--java/
| |--a1/
| | |--class_File1.java
|--flavour2/
| |--java/
| |--a1/
| | |--class_File1.java
|--main/
|--java/
| |--...
|--res/
| |--raw/
| | |--comments.txt
| |--...
|--AndroidManifest.xml
and I use a build.gradle file like this one
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 10
targetSdkVersion 21
}
packagingOptions {
exclude 'assets'
exclude '**/comments.txt'
}
sourceSets {
flavour1 {
resources {
exclude '**/comments.txt'
}
}
flavour2 {
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
flavour1 {
packagingOptions {
exclude 'assets'
exclude 'res/raw/comments.txt'
}
}
flavour2 {
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
}
Generally speaking, I have experimented a lot. I have tried packagingOptions, exclusion in sourceSets but nothing seems to work. What I am trying to achieve is not include for example in the .AAR archive the file comments.txt and the folder "assets" which is an optional folder. I examine each time the .AAR file by renaming it to zip and looking into the files included.
I have also looked into the documentation here, where maybe configurations could be a solution but I am not sure how to use it or how to move forward. Any help will be appreciated.