Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raw assets duplicated when building apk

Tags:

android

apk

When building my application APK, the final APK is twice as big as my Eclipse project folder. I was perplexed as to why this was happening, I'd like to keep my app as small as possible.

I've recently had to recover my application source by extracting from a released APK, I found out why the APK is so big, I use about 30 audio samples, saved as ogg files in /res/raw/. When the APK is built, an additional /raw folder is created in the root of the APK, with a duplicate of all of my ogg files.

Is there a way to stop these files being duplicated, is Eclipse/ant telling me the files should be in a /raw folder in the root of my project, instead of /res/raw?

like image 990
Digitale Avatar asked Jan 01 '26 00:01

Digitale


2 Answers

The APK file will contain a res/raw/ directory, containing the sole copy of your raw resources for that APK. Eclipse and Ant will not add a /raw directory to your APK, at least not if you use a normal build process.

For example, you examine this sample project, you will find that the resulting APK file has one copy of the OGG raw resource, not two.

like image 184
CommonsWare Avatar answered Jan 02 '26 16:01

CommonsWare


what happened between normal apk structure and duplicated one

enter image description here

how to duplicate this issue, by using res folder as source folder (add to build path) enter image description here

remove res folder from build path would do the job enter image description here

like image 32
Mia Avatar answered Jan 02 '26 17:01

Mia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!