Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ymasory committed Mar 10, 2012
0 parents commit f811357
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 0 deletions.
27 changes: 27 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:a="http://schemas.android.com/apk/res/android"
a:versionCode="1"
a:versionName="1.0.0-SNAPSHOT"
package="com.example"
>

<uses-sdk
a:minSdkVersion="8"
a:targetSdkVersion="8"
/>

<application
a:debuggable="true"
a:label="@string/app_name"
a:icon="@drawable/android:star_big_on"
a:installLocation="auto"
>
<activity a:name=".MainActivity">
<intent-filter>
<action a:name="android.intent.action.MAIN" />
<category a:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
- [email protected]
- http://combinatory.net
- http://yuvimasory.com

96 changes: 96 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>

<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>prototype</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>Maven Android Scala Prototype</name>


<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>


<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.9.1</version>
</dependency>
</dependencies>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.13.1</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<emulator> <avd>wvga</avd> </emulator>
<manifest> <debuggable>true</debuggable> </manifest>
<proguard>
<config>proguard.cfg</config>
<skip>false</skip>
</proguard>
<sdk> <platform>8</platform> </sdk>
<test> <skip>true</skip> </test>
<undeployBeforeDeploy>false</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
49 changes: 49 additions & 0 deletions proguard.cfg
Original file line number Diff line number Diff line change
@@ -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 <methods>;
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(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 *;
}
11 changes: 11 additions & 0 deletions res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
a:gravity="center"
a:layout_width="match_parent"
a:layout_height="match_parent"
a:padding="5dp"
a:text="@string/app_name"
a:textSize="20sp"
a:textStyle="bold"
xmlns:a="http://schemas.android.com/apk/res/android"
/>
4 changes: 4 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Maven Android Scala Prototype</string>
</resources>
12 changes: 12 additions & 0 deletions src/main/scala/MainActivity.scala
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit f811357

Please sign in to comment.