Android assets folder not added to apk - android

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

Related

Android studio removes my file/folder in packages (in android package) automatically, how to prevent?

I create a folder in android package path (in this path: app\build\generated\source\r\debug\android\ ) named "print" to put my files.
Application works well but after a while it removes automatically and must create and copy my files again.
I unchecked "Optimize imports on fly" in Settings>Editor>General>AutoImport but again deleted my file (same as checked).
I don't understand why it deletes that file and folder, You have any solution?
You have to put the file inside the src folder ,not the build folder.
screenShot showing where the file should be
You are putting your folder inside an Android generated folder. That will get regenerated every time you rebuild. You will have to put your files elsewhere. If they are media files, put them in a resource folder. Otherwise, assets works too.

Why can't I see `assets` folder in my Android package installation folder

I'm browsing with DDMS my application's installation folder /data/data/com.my.app and I can't find where the assets folder is. I'm using it inside my application using URI file:///android_assets/...
I can't find where the assets folder is
That is because there is no assets folder on the device. The assets, like your resources, are packaged into the APK file. Assets are not unpacked as part of APK installation. file:///android_asset/, for those things that understand it, knows to look inside of the assets in your APK.

How to put extra files in Android APK with Eclipse?

I want to add a text file to my APK root. This file will not be used in the application but it will stay there for manual extraction of the APK.
I tried to put it into the root of the project in Eclipse but it didn't include that file in the APK. I don't want to put it into assets folder. Can't I put it to the root?
Use the assets folder.
According to Android developer
assets/
This is empty. You can use it to store raw asset files. Files that you save here are compiled into an .apk file as-is, and the original filename is preserved. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager. For example, this is a good location for textures and game data.
Files that are not put into any of the main directories of your android project will NOT be included in your apk. You MUST put the file in the assets so it can be accessed within the application as an external resource/file.

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

Which files are included in APK file

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.

Categories

Resources