Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can scala applications for android be reduced in file size?

I am attempting to write Android applications with Scala in Eclipse. The problem I'm running into is that the deployed APK file is much too large - since you can't link Android apps to external libraries, any code used has to be copied into the APK file, but most Scala apps don't need most of the Scala library. Somewhere I read that even a large application can be packaged with only 50kb or so of the Scala library, compared to the 4mb that my Android device is telling me my test app takes up.

I've already tried the Treeshaker plugin for Eclipse, and I can see in the progress window that it is running, but it doesn't seem to do anything. Disintegrating it from my project doesn't have an impact on the final file size. I've also tried configuring Proguard myself, but I can't find a configuration that doesn't either not affect the file size (and I realize that Proguard only runs when use Eclipse's export wizard, which I used to test this) or crash with cryptic error messages, such as "1". (Well, ok, the entire error message is "Conversion to Dalvik format failed with error code 1", which is hardly more helpful because I can't find any clear documentation of that error message and it doesn't tell me what part of my code or configuration is causing the problem...)

So. Any insight on how I can get this working?

like image 382
Flaise Avatar asked Jan 04 '12 20:01

Flaise


People also ask

Which image codec should be used for optimize APK size?

You can reduce PNG file sizes without losing image quality using tools like pngcrush, pngquant, or zopflipng. Use WebP file format and Use vector graphics.


2 Answers

Most people use SBT with ProGuard (as far as I know it is run automatically with the sbt android plugin).

Additionally, there is the possibility to ship with two dex files in a apk. This also solves many problems, because most restrictions apply to the dex files, not the final apk.

This is older, but has many useful general information: http://lamp.epfl.ch/~michelou/android/

like image 171
soc Avatar answered Nov 14 '22 21:11

soc


I use AndroidProguardScala as given here:

https://stackoverflow.com/a/11084146/1287856

It uses Proguard when exporting the application, and it works pretty well.

like image 42
Mikaël Mayer Avatar answered Nov 14 '22 19:11

Mikaël Mayer