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?
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.
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/
I use AndroidProguardScala as given here:
https://stackoverflow.com/a/11084146/1287856
It uses Proguard when exporting the application, and it works pretty well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With