Background
I'm making a library of components that will be used to build Mongolian vertical script apps. Because of Unicode rendering issues, I need to include a Mongolian font with the library. For some apps this is enough. But for other apps, a few fonts are needed. Including these extra fonts significantly increases the size of the library.
Aim
I would like it make it as easy as possible for developers to exclude the extra fonts if they don't need them in their project.
Related
I saw that there are ways to remove unneeded resources from a library:
- Remove not needed resources from android library in apk
- removing unused assets from 3rd party library
However, these are things the developer has to figure out. From the perspective of the library creator, is there anything I can do to make this a very simple implementation for the developers using my library?
Possible solution
I could, of course, have two different versions of the library which are identical except for the number of resources. But this "solutions" sounds like bugs waiting to happen.
Things I've read
- Building your own Android library (Codepath)
- Create an Android Library (Android documentation)
- How to create a library project in Android Studio and an application project that uses the library project
I see something in the documentation about "non-default variants". This looks promising but I don't understand how/if this works for including/excluding resources.
Update
I'm including the dependency section of the build.grade files for the library and a demo-app that uses the library.
build.gradle (Module: mongol-library)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
testCompile 'junit:junit:4.12'
}
build.gradle (Module: demo-app)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support:recyclerview-v7:25.3.0'
compile project(":mongol-library")
testCompile 'junit:junit:4.12'
}
These links also look like they will be helpful: