Search code examples
androidandroid-gradle-pluginaar

Can be contents, marked as "obligatory" by Google excluded from aar?


I'm writing an android library, that doesn't contain any resources.

Google in documentation (https://developer.android.com/studio/projects/android-library.html#aar-contents) says, that /res/, R.txt and public.txt is obligatory

Whats the effect of excluding that files in production? Does this affect application after build? Or can this files be successfully removed from aar lib?


Solution

  • Library modules provides functionality(including UI) which can be used by app. App can use these functionality(which will use res) from library module. So it is common to have res in library module. It is also common to not have any content inside res folder, it might just act as placeholder. If you want to remove certain file from production, modify the app build.gradle.

    android {
     packagingOptions {
            exclude 'error_prone/Annotations.gwt.xml'
        }
    }