Which files are included in APK file - android

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.

Related

How can I customize the destination of where dependencies resources are placed in an APK?

I am looking for a way to customize where an android application places any of its dependencies resource files. These properties files are part of resource directories in jar dependencies.
I've looked at the aapt documentation's aaptOptions and packagingOptions of the Android DSL docs, but can't find any way to manipulate the destination of assets, res, resources files found in a projects dependencies.
Here's an example of the APK when viewed the APK Analyzer built into Android Studio. The blacked out names of properties files are the ones I'd like moved into assets or res folders.
I'd like for them to be placed into the assets or res folders of the APK rather than in the root path of the apk.
You can't choose where files are placed in the APK.
The structure is like that, so when the APK is unpacked on device, the Android system knows how to handle the files and where they are located.
If you could randomly move files around and into other folders, it would completely break the installation of APK files.

How can I tell if a jar file is being compiled into an apk?

In our Unity project we have a lot of jar files in Assets/Plugins/Android. I understand when Unity compiles for Android, any .jar or .aar files in that directory will make it into the compiled apk.
However, our app's Unity project has many folders next to the Assets folder, and in one of those is a hand full of jar files, such as android-support-V4.jar and google-play-services.jar. These are not in Assets/Plugins/Android, but some of the .jars in that directory depend on what's in the directory outside the Assets folder.
How can I tell if these .jars outside the Assets folder are making it into the compiled apk? I know it's a broad question, and part of it is idiosyncratic to how my company's project is set up, but basically I'm wondering if there are common or known ways to get .jars outside of the Assets folder into the apk Unity makes.
You can use a tool such as Classyshark to analyze the contents of your apk. Classyshark is developed by Google for these kinds of inspections. You can see what packages and what classes are in your apk, no matter how these were packaged.

Install resource file into root of apk

When you use a jar as a dependency, any files in the jar root are put into the generated apk's root. Meanwhile, if I just have my android project, and I want to put files in the root, I can't! I have to put files in res/assets or res/raw, which won't do the trick for me.
I'm using a library internal to the company, and it expects a filename for something in the top-level of the produced artifact
With old android projects (the ones that use ant, etc), put your resource files in /resources (not /res) to ensure that they aren't touched by aapt and are put in the root.
For new android projects (ones using gradle), put these resources in src/main/resources

include/exclude files in apk

In an android eclipse project, I have a directory like assets/gfx. In this directory are files like mysprite.png, but I also have mysprite.xcf, the original gimp file. Is this file included in the apk file, and if so, is there a way to exclude it from the build of the apk file?
First, yes. this files are present in your apk as well as /res files.
Second, no. You cannot modify apk contents(delete, add, ..). You may keep them (for example picture) on SD card

Android assets folder not added to apk

I'm pretty new to eclipse and Android and I'm trying to add some files to the assets folder, but certain files and directories are not being included in the .apk file.
I have set-up the following structure in the solution:
/assets
/textures
/test.png
/splash.png
/xml
/testData.xml
I don't know if there is a specific way to get eclipse to re-build/compile the project and add the new assets to the assets folder in the .apk, but the /xml subfolder (and its contents) are not in the apk. Subsequently I get FilenotFoundExceptions thrown when I deploy the app. The textures are all included.
How can I force a recompile and rebuild of the apk and is there anywhere to manually check which files are included in the project (like an assets manifest file)?
As far as I know there are no restrictions placed on hierarchy or file formats for within the assets folder. Also, when I dragged the files from the desktop to the solution explorer, I selected 'copy files to project'.
Thanks
It appears one cannot use upper-case letters in the naming of files within the assets folder. Contrary to my example above, I was actually using camel-backed file names within the folders. After changing the file names to lower-case, the apk was automatically re-built with the assets the next time I deployed

Categories

Resources