简体   繁体   中英

Is it safe to exclude libraries' assets (font in this case) from an Android Gradle build?

As the title says, is it safe to exclude libraries assets from an Android Gradle APK build ?

One of the Google's libraries is importing a font (~7mb). Could this file be excluded safely to reduce APK size?

在此处输入图片说明

My current method to exclude files is to use an ignoreAssetsPattern statement:

android {
    ...

    buildTypes {
        ...

        release {
            ...

            aaptOptions {
                ignoreAssetsPattern '!NotoColorEmojiCompat.ttf:'
            }
        }
    }
}

is it safe to exclude libraries assets from an Android Gradle APK build ?

Generally speaking, no. The library is expecting the asset to be there.

If you feel that you have sufficient test coverage, and so you feel comfortable that you are not using the feature of this library that requires this asset, you're welcome to try excluding it.

IMHO, a better solution is to figure out what library this is coming from (my guess: Jetpack's Emoji library) and remove your code that depends upon it, so you can then remove the whole library from the project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM