Tech Tips

  1. 未分類
  2. 14 view

[Android][Scala][Windows7]Develop Android App with Scala


Scala is better than Java for me,
So I’ll try to develop Android app with scala.
Actually, I wanted to use Ubuntu but it doesn’t work because of USB matter with Virtual Box.
That’s why I choose Windows.

0. Install JDJ

Download “Java SE Development Kit” and istall it from following URL. Add following value to environment variable “path”.
C:\Program Files\Java\jdk1.7.0_51\bin;

1. Install Scala

Install Scala from following URL.

2. Install sbt

Download sbt-launch.jar from following URL,
decompress it and install it to “C:\sbt”. Make new file “C:\sbt\sbt.bat” with following content.
set SCRIPT_DIR=%~dp0
java -Dinput.encoding=Cp1252 -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -jar "%SCRIPT_DIR%sbt-launch.jar" %*
Add following value to “path” environment variable.

3. Install Android SDK

Download “Android SDK” from following URL, decompress it and install it to “C:\”. And then add following value to “path” environment variable.
adt-bundle-windows folder name is up to version and CPU type.
C:\Program Files (x86)\scala\\bin;C:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\platform-tools;C:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\tools;

4. Make project

4-a. Install Android Platform

Double click
C:\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\SDK Manager.exe
and install package.
Everything of Tools and Extras, and some versions.

4-b. Make project template

Check targets with following command.
$ android list
id: 14 or "android-19"
     Name: Android 4.4.2
     Type: Platform
     API level: 19
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
     ABIs : armeabi-v7a
Make project template.
$ android create project --target "android-19" --name ScalaTestApp --path "C:\Users\zuqqhi2\Desktop" --activity MainActivity --package org.example.scalatestapp

4-c. Write Scala

Make following new 3 files under scalatestapp folder.
import android.Keys._


name := "ScalaTestApp"

platformTarget in Android := "android-18"

run <<= run in Android

install <<= install in Android
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.0.6")

4-d, Make MainActivity to Scala

package org.sample.scalatestapp;

import android.os.Bundle;

class MainActivity extends Activity{
  override def onCreate(savedInstanceState:Bundle){

4-e. Compile

$ cd scalatestapp
$ sbt
> compile
> android:package-debug

5. Install real device

Do setting with USB connection with Android from following URL. Connect PC and Android with USB.
Go “Setthing”->”Android Information”->”Build Target” and tap for 7 times.
And then,
turn “Setting”->”Development Option”->”USB Debug” on. Check following command’s result.
$ adb devices
List of devices attached
****** device
Install .apk file to real device with following command.
adb install -r bin/ScalaTestApp-debug.apk

未分類 recent post

  1. Install sbt 1.0.0 and run sample template

  2. Visualization of Neural Network and its Train…

  3. [Machine Learning]Created docker image includ…

  4. [Node.js]How to write batch script with Node.…

  5. Web Server Contribution by Vagrant and Ansibl…