Android: How to copy files to asset folder during build - android

I am developing a cross-platform project(iOS and Android).
I have a /resource folder that contain some .png files.
I know that only the files that in /asset folder are compiled into the .apk file.
Now I need copy the files from /resource to /asset folder manually.
It is too inconvenient.
Is is possible to copy files in /resource to /asset during build project automatically?
(p.s. I am using Eclipse for development.)

Related

assets folder missing in LibGDX project

I need to add some files to my android/assets folder of my project however, it isn't there ? I may have accidentally deleted it without knowing.
how do I create the assets folder?
Android studio doest provide ASSETS folder by default
you have to create it from
For the Android plugin, extra files and folders specific to Android:
AndroidManifest.xml
res/
assets/
aidl/
rs/
jni/
jniLibs/
Please read where to place asset folder

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.

add custom .properties file in unity android package

I have a .properties file that is required by some android java unity plugin that I am writing. I need to add this file to the unity app's package somehow, so once the unity IDE builds the .apk, the file is located in the root of the apk's assets folder.
Where and how do I place this file in the Unity IDE? I tried putting it under Assets, but I inspected the resulting .apk file and the file did not make it there..
any ideas?
tnx
You have two options for including files accessible at runtime:
Managed assets in Ressources folders accessible via Resources.Load
Un-managed assets in the StreamingAssets folder accessible via the File or WWW APIs
Your .properties file should probably reside in the StreamingAssets folder, if you don't need Unity3D to process it. Unity3D will optimize assets in the Resources folders. For example an image will have to set as GUI or Texture in the IDE. Assets in the StreamingAssets folder are raw and not processed by the Unity3D IDE. So a png is a still a regular png at runtime. StreamingAssets is where we store mp4 mobile videos we don't want Unity3D to re-encode.

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.

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