I am trying to get a hello world android app work with scala and intellij Whoever tried the same feat must be familiar with the following steps. The problem happens at the end when I am using the sbt
Please note the versions for each tool I use. For starters I am using the java version 1.7.0_07
-Download and setup the android sdk. I have downloaded all versions from 1.5 (API 3) to 4.1 (API 16). I will not go into further details on this. There are many tutorials already.
We are going to need the android home path in an enviroment variable. So let's set a persistant enviroment variable for the current user
gedit ~/.pam_environment
and now append this: ANDROID_HOME= e.g.
ANDROID_HOME=/home/pligor/android-sdks
Now let's grab the sbt tool. We would rather have a manual installation of sbt. Find the “Unix” section in the link: https://github.com/harrah/xsbt/wiki/Getting-Started-Setup and download sbt-launch.jar and place it in ~/bin Currently this is version 0.12.0 Then create an sbt file:
gedit ~/bin/sbt
write this line inside:
java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -jar `dirname $0`/sbt-launch.jar "$@"
and make script executable:
chmod u+x ~/bin/sbt
Now you need to install an sbt plugin for the intellij. The sbt-idea version 1.1.0:
gedit ~/.sbt/plugins/build.sbt
add append inside the line (remember each .sbt files seperates each statement by an extra empty line):
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.1.0")
For github templates you need the giter8 tool. So execute:
curl https://raw.github.com/n8han/conscript/master/setup.sh | sh
and then execute:
cs n8han/giter8
Now I use the g8 to get an android app template from jberkel:
g8 jberkel/android-app
There are some questions for you to setup. Currently I leave everything to default. Which means I use scala version 2.9.1 and Android 2.3.3 (API 10) and scalatest_version of 1.8.RC1. I am not accustomed with proguard since I haven't use it before so I set useProguard to false.
Before you run sbt: The android-plugin is currently compatible with the 0.11.3 version of sbt we need to make an adjustment. So inside the folder of the new android application execute: gedit project/build.properties and insert this line: sbt.version=0.11.3
Inside the same folder execute: sbt 'gen-idea no-classifiers' compile
and then go to the sbt interactive mode console: sbt
Inside the console execute: android:package-debug
And I believe these kind of warnings is where the problem starts: trouble processing: bad class file magic (cafebabe) or version (0033.0000) ...while parsing my/android/project/R$id.class
Now you can try to start an android emulator: android:emulator-start # use to get a list of avds e.g. android:emulator-start android2_3_3
after the emulator is fully started execute the android app like that: android:start-emulator
AND AFTER ALL THIS THE APP WILL CRASH !!