From f811357538f1a6a460a565600d2dc24b7fbf1bbc Mon Sep 17 00:00:00 2001 From: ymasory Date: Sat, 10 Mar 2012 09:57:39 -0500 Subject: [PATCH] first commit --- AndroidManifest.xml | 27 +++++++++ README.md | 63 ++++++++++++++++++++ pom.xml | 96 +++++++++++++++++++++++++++++++ proguard.cfg | 49 ++++++++++++++++ res/layout/activity_main.xml | 11 ++++ res/values/strings.xml | 4 ++ src/main/scala/MainActivity.scala | 12 ++++ 7 files changed, 262 insertions(+) create mode 100644 AndroidManifest.xml create mode 100644 README.md create mode 100644 pom.xml create mode 100755 proguard.cfg create mode 100644 res/layout/activity_main.xml create mode 100644 res/values/strings.xml create mode 100644 src/main/scala/MainActivity.scala diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..a1bf3da --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..20c65fd --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# Maven Android Scala Prototype # +This setup works. We use it with multiple clients. + +## Setup ## +- Install JDK 1.5+. +- Install the Android SDK. +- Install Maven 3.0.3+. +- Set the ennvironment variable `ANDROID_HOME` to the path of your Android SDK. +- Add `$ANDROID_HOME/tools` and `$ANDROID_HOME/platform_tools` to your `$PATH`. + +## Compile & Run on Attached Device or Running Emulator ## + + $ mvn clean install android:deploy + +## Help ## + + $ mvn android:help + +## Improvement ## +I'm trying to figure out how to: + +- Avoid running ProGuard during development mode +- Reduce the jar search path to avoid all the duplicate jars that ProGuard wastes time on +- Integrate ProguardCache (banshee/ProguardCache) +- Introduce multiple modes, one for development and one for deploy +- Specify the key to sign with + +If you can do any of these things, please send me a pull request on GitHub. + +## Troubleshooting ## + +### Device permissions ### +On recent versions of Ubuntu you may get a permission denied error +trying to develop with a physical phone. You will also see this in sbt: + + $ adb devices + List of devices attached + ???????????? no permissions + +To solve this problem, create the file `/etc/udev/rules.d/51-android.rules` and +paste these contents: + + SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666" + SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666" + SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666" + SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="0c01", + MODE="0666", OWNER="[me]" + SUBSYSTEM=="usb", SYSFS{idVendor}=="19d2", SYSFS{idProduct}=="1354", MODE="0666" + SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", SYSFS{idProduct}=="681c", MODE="0666" + +Then run `sudo service udev reload`, unplug and replug the device, and things should work: + + $ adb devices + List of devices attached + 015A7A370900601C device + +## Contact ## + +- If you have questions, I suggest you email the scala-on-android Google group (https://groups.google.com/forum/?fromgroups#!forum/scala-on-android) and CC me. +- yuvi@combinatory.net +- http://combinatory.net +- http://yuvimasory.com + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ea227dc --- /dev/null +++ b/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + com.example + prototype + 1.0.0-SNAPSHOT + apk + Maven Android Scala Prototype + + + + + scala-tools.org + Scala-tools Maven2 Repository + http://scala-tools.org/repo-releases + + + + + scala-tools.org + Scala-tools Maven2 Repository + http://scala-tools.org/repo-releases + + + + + + + com.google.android + android + 2.2.1 + provided + + + org.scala-lang + scala-library + 2.9.1 + + + + + + UTF-8 + UTF-8 + + + + + + org.scala-tools + maven-scala-plugin + 2.13.1 + + + scala-compile-first + process-resources + + add-source + compile + + + + scala-test-compile + process-test-resources + + testCompile + + + + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + 3.1.1 + + wvga + true + + proguard.cfg + false + + 8 + true + false + + true + + + + diff --git a/proguard.cfg b/proguard.cfg new file mode 100755 index 0000000..1158962 --- /dev/null +++ b/proguard.cfg @@ -0,0 +1,49 @@ +-dontobfuscate +-dontoptimize +-dontpreverify +-dontwarn + +-dontnote scala.Enumeration +-dontnote org.xml.sax.EntityResolver + +-keep public class scala.Option +-keep public class scala.Function0 +-keep public class scala.Function1 +-keep public class scala.collection.Seq +-keep public class scala.collection.immutable.Map +-keep public class scala.collection.immutable.List +-keep public class scala.collection.immutable.Vector +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.appwidget.AppWidgetProvider +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.preference.Preference +-keep public class * extends android.view.View + +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml new file mode 100644 index 0000000..5dbb0b8 --- /dev/null +++ b/res/layout/activity_main.xml @@ -0,0 +1,11 @@ + + diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..192d6d0 --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Maven Android Scala Prototype + diff --git a/src/main/scala/MainActivity.scala b/src/main/scala/MainActivity.scala new file mode 100644 index 0000000..526cd55 --- /dev/null +++ b/src/main/scala/MainActivity.scala @@ -0,0 +1,12 @@ +package com.example + +import android.app.Activity +import android.os.Bundle + +class MainActivity extends Activity { act => + + override def onCreate(saved: Bundle) { + super.onCreate(saved) + act setContentView R.layout.activity_main + } +}