Skip to content
aguestuser edited this page Jan 4, 2015 · 4 revisions

Getting started with Android

TOC

### Scaloid

It seems like the best platform to build object-functional programs on Android is Scaloid. Here are some reference materials about Scaloid:

### notes on scaloid install
  • needs target
  • run android list targets first
  • choose an id (one corresponding to API v 21) -- for me it's 1
  • run android update project -p . -t 1 (or replace 1 with id like android-21

steps to edit Run/Debug config don't happen automatically

  • to do it manually:
    • select Run/Edit Configuration from Menu
    • select Android Application from lefthand pane
    • look for tab that says before Launch
      • delete run Make
      • click plus button
      • select SBT from dropdown
      • paste android:package-debug into text field

config and compile errors:

  • on Project Import, following dependency warnings were triggered:
[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn] 	* net.sf.proguard:proguard-base:4.11 -> 5.0
[warn] Run 'evicted' to see detailed eviction warnings
  • compiling fails with errors:
    • first:
    Error:scalac: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /Users/aguestuser/Library/Android/sdk/platforms/android-21/android.jar(java/lang/Object.class)
    
    • second:
    Error:scalac: Error: object scala in compiler mirror not found.
    scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
    at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
    
### IDE & Build tool

At the moment, it's sort of a toss-up between:

  1. Android Studio as the IDE with Gradle as the build tool
  • pros:
    • this is by far the most common platform for Android developers. Googling our problems will be easier.
    • it just got revamped and is extremely well documented by Google
    • Android Studio is built on top of InteliJ, so we can still get most of the cool features we would have gotten from it, plus possibly more cool features (ie: tightly integrate running and testing on emulators or devices) that might not be available on vanilla InteliJ
  • cons:
    • it enforces use of gradle as the build tool, but sbt seems to be the most common build tool used on Scala projects
    • it seems intended for use with Java, not Scala
  1. InteliJ as the IDE with sbt as the build tool
    • pros:
      • allows use of sbt, which seems like the more common build tool for Scala developers
      • might have more robust features for supporting Scala development
    • cons:
      • is (perhaps?)not as widely in use by Android developers
      • is not officially supported or documented by Google (unlike Android Studio)
      • using sbt might put us at odds with other Googlable examples of what we're trying to do

Some resources to help make the decision:

### Android Tooling

This can be a pain, and I have still not succeeded at getting an emulator up and running. Below are the steps I took to get the design environment set up. Your mileage may vary.

A couple decent walkthroughs of setting up the design environment:

JDK

Android Suite

  • download from ___ and follow instructions
  • will automatically install Android SDK and launch Android SDK Manager

Android SDK

  • can be installed as stand-alone (i didn't do this)

    • brew version is out-of-date?
  • from Android Suite install:

    • default install location: ~/Library/Android/skd
  • after install, set path files in ~/.bashrc as follows:

    export ANDROID_HOME="/Users/aguest/Library/Android/sdk"
    export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
    
  • launch Android SDK Manager

    • launched automatically after install?
    • from welcome dialogue, click "Configure"
    • or from CL: android sdk (after setting path)

AVD (Android Virtual Device)

  • config:

    • choose device, target OS, chipset, memory allocation
    • be sure to allocate enough memory in HAXM to run it!
  • launch

    • from CL: android avd
    • from Android Suite: ??

HAXM (Hardware Accelarated Execution Manager)

  • necessary to make yr emulator not run at snail's pace

  • default install doesn't seem to work

  • Default Install (doesn't work!):

    • is an option in Android SDK Manager
    • dmg located at: ~/Library/Android/sdk/extras/intel/Hardware_Accelerated_Execution_Manager/
    • default RAM allocation is 1024, often not enough for emulators
    • to re-install nav to dmg, run package installer, reset memory
  • Manual Install

  • Checks:

    • that it exists: kextstat | grep intel -> look for status message showing that com.intel.kext.intelhaxm is loaded
    • to stop (doesn't work): sudo kextunload –b com.intel.kext.intelhaxm
    • to start (doesn't work): sudo kextload –b com.intel.kext.intelhaxm
    • to uninstall: sudo /System/Library/Extensions/intelhaxm.kext/Contents/Resources/uninstall.sh

Emulator