Which files are included in APK file

青春壹個敷衍的年華 提交于 2019-12-23 09:42:02

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/10927205/which-files-are-included-in-apk-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!