APK文件中包括哪些文件[英] Which files are included in APK file

本文是小编为大家收集整理的关于APK文件中包括哪些文件的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我在我的Android应用程序中有很多未使用的图像.这些图像放在项目根目录中的单独文件夹中.他们没有在项目中的任何地方使用,但我需要保持它们.

我的担忧是将这些未使用的图像包含在APK文件中?由于它们有很多并增加APK文件的大小.

推荐答案

存储在根目录(包括自定义子目录)中的文件是 not 在APK中.有一个很常见的做法是在项目根目录中拥有自己的项目所需的文件.例如,源许可证文件,待办事项列表,带有高分辨率映像的目录,您可以从中创建分布式图像等.

android使用具有特殊含义的这些子目录:

  • src/
  • res/
  • 资产/
  • libs/
  • Gen/
  • bin/

使用除了那些以外的子目录名称,Android将忽略您的文件.

其他推荐答案

通过您的自我确认:创建APK并将扩展更改为zip并提取. 您可以使用Progaurd等APK优化器,更适用于相同.

其他推荐答案

addon到@ darshan-josiahburber s出色的答案

使用Android-Studio-0.5.8,Gradle-1.11和Android-Tools.0.9.+您也可以包含一个文件夹

  • resources

要将文件相对于Android APK的根复制.

示例:

  • 项目文件file res/some/dir/file.txt将被复制到APK/RES/SOME/DIR/FILE.txt
  • 项目文件资产/某些/dir/file.txt将被复制到apk/ssets/some/dir/file.txt
  • 项目文件资源/某些/dir/file.txt将复制到APK/some/dir/file.txt

此文件夹resources是必要的,如果要包含由ICAL4J等的Crossplatflub Libs使用的*.properties文件.

本文地址:https://www.itbaoku.cn/post/1937956.html

问题描述

I have a lot of unused images in my android app. Those images are placed in separate folder in project root directory. They are not being used anywhere in a project, but I need to keep them.

My concern is that will these unused images be included in the apk file? Since there are a lot of them and increase the size of apk file.

推荐答案

Files stored in the root directory (including custom subdirectories) are not included in the APK. It is very common practice to have your own files needed for the project in the project root. For example, a source license file, a to-do list, a directory with high-resolution images that you create distributed images out of, etc.

Android uses these subdirectories with special meaning:

  • src/
  • res/
  • assets/
  • libs/
  • gen/
  • bin/

Using a subdirectory name other than those, Android will ignore your files.

其他推荐答案

Confirm by your self: create the apk and change the extension to zip and extract that. You can use an apk optimizer like progaurd and more for same.

其他推荐答案

addon to @Darshan-JosiahBarber s excellent answer

With android-studio-0.5.8, gradle-1.11 and android-tools.0.9.+ you can also have a folder

  • resources

for files to be copied relative to the root of the android apk.

Example:

  • project file res/some/dir/file.txt will be copied to apk /res/some/dir/file.txt
  • project file assets/some/dir/file.txt will be copied to apk /assets/some/dir/file.txt
  • project file resources/some/dir/file.txt will be copied to apk /some/dir/file.txt

This folder resources is necessary if you want to include *.properties files used by crossplatform libs like ical4j.