简体   繁体   English

APK文件中的无用资源

[英]Useless resources in APK file

I've got problem with very simple application. 我在使用非常简单的应用程序时遇到了问题。 APK size is now 3 MB , but it contains a lot of useless for me files (I think that source of this files is Support Library ). APK大小现在为3 MB ,但其中包含许多对我来说无用的文件(我认为该文件的来源是Support Library )。 In my application I don't use any images, but all drawable directories contains a lot of icons, buttons, etc. Is it possible to delete this images by any rule in gradle or other method? 在我的应用程序中,我不使用任何图像,但是所有可绘制目录都包含许多图标,按钮等。是否可以通过gradle或其他方法通过任何规则删除此图像? I use Android Studio. 我使用Android Studio。

Already I added to build.gradle information about languages to include in APK. 我已经添加了build.gradle有关要包含在APK中的语言的信息。 I had in Hello World 80 languages before it. 我之前使用过Hello World 80种语言。

Screen of files: 文件屏幕:

在此处输入图片说明

The Gradle build system for Android supports " resource shrinking ": the automatic removal of resources that are unused, at build time, in the packaged app. 适用于Android的Gradle构建系统支持“ resource shrinking ”:在构建时,打包应用程序会自动删除未使用的资源。 In addition to removing resources in your project that are not actually needed at runtime, this also removes resources from libraries you are depending on if they are not actually needed by your application. 除了删除项目中在运行时实际不需要的资源之外,这还将从您所依赖的库中删除资源,如果您的应用程序实际上不需要这些资源。

To enable this add the line shrinkResources true in your gradle file. 要启用此功能, shrinkResources true在gradle文件中添加一行shrinkResources true

    android {
        ...

        buildTypes {
            release {
                shrinkResources true
            }
   }
}

Check the official documentation here, 在此处查看官方文档,

http://tools.android.com/tech-docs/new-build-system/resource-shrinking http://tools.android.com/tech-docs/new-build-system/resource-shrinking

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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