Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala Programming for Android

People also ask

Can Scala be used for Android?

While you can use Scala with Gradle, it does not work well in an Android project. gradle-android-scala-plugin exists in an attempt to support Scala for Android, but it hasn't been actively maintained for some time now. The documentation suggests that it only works up to API 23.

What is Scala Android?

It got the attention of Android app developers due to its list of added functionalities to the native JAVA language. Scala is a hybrid object-oriented programming language created with an emphasis on functional programming inclinations such as immutability. Let's look at how Scala was launched and its few key features.

Is Scala used for app development?

Statically typed Java language pushed as alternative to JRuby and Groovy for building mobile Android apps. Scala, a statically typed language running atop the Java Virtual Machine, is emerging as a development option for building Google Android applications.

Can I use C++ on Android?

The Android Native Development Kit (NDK): a toolset that allows you to use C and C++ code with Android, and provides platform libraries that allow you to manage native activities and access physical device components, such as sensors and touch input.


I've written some basic Android applications in Scala, nothing too epic. Not being a Java programmer I was suggested to use a "treeshake", I was explained by a friend that this strips out all the unnecessary libraries from the jar files.

I have not documented it, but I found that someone else already has:

http://chneukirchen.org/blog/archive/2009/04/programming-for-android-with-scala.html

Proguard is not the only solution, you might find something that suits your work flow or is more suited for your environment.

Additionally google have just realised JACK , which deals with quite a lot of reducing build and memory times see https://source.android.com/source/jack.html


You can now use the Android plugin for Gradle to create Android applications in Scala. It incorporates the ProGuard tool to trim the fat from the resulting APK file, so seems to meet your needs.

https://github.com/jvoegele/gradle-android-plugin/wiki


There is also an plugin for the Scala-based builder sbt: sbt-android-plugin.


For tutorials and examples, see also Stéphane Micheloud's "Exploring Android" page: http://lamp.epfl.ch/~michelou/android/


I verified this detailed solution with Eclipse 3.7, Scala 2.10 and the plug-in AndroidProguardScala v50:

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

Everything works fine. A simple test application with scalafied main activity class only takes 38Kb. Libraries projects are supported. Proguard is activated when exporting the project.