Git Product home page Git Product logo

android-plugin's Introduction

Build Scala Android apps using Scala

NOTE: this plugin is currently not actively maintained. Have a look instead at android-sdk-plugin.

sbt-android-plugin is an extension for the Scala build tool sbt which aims to make it as simple as possible to get started with Scala on Android.

Together with giter8 you can create and build a simple Android Scala project in a matter of minutes.

Getting started

See the Getting started guide on the wiki for more documentation. In case you're not not familiar with sbt make sure to check out its excellent Getting Started Guide first.

Hacking on the plugin

If you need make modifications to the plugin itself, you can compile and install it locally (you need at least sbt 0.11.x to build it):

$ git clone git://github.com/jberkel/android-plugin.git
$ cd android-plugin
$ sbt publish-local

Migrating from 0.7.x

For those who are familiar with the 0.7.x plugin, there is a migration guide for a quick reference. The 0.7.x version is no longer maintained - but it is still available in the 0.7.x branch.

Mailing list

There's no official mailing list for the project but most contributors hang out in scala-on-android or simple-build-tool.

You can also check out a list of projects using sbt-android-plugin to see some real-world examples.

Credits

This code is based on work by Walter Chang (saisiyat), turned into a plugin by Mark Harrah, and maintained by Jan Berkel.

A lot of people have contributed to the plugin; see contributors for a full list.

Build Status

android-plugin's People

Contributors

appamatto avatar chacal avatar ezh avatar fabianpage avatar fxthomas avatar glenviewjeff avatar groves avatar harrah avatar jamur2 avatar jberkel avatar jbrechtel avatar jrudolph avatar kriomant avatar loganj avatar lolsborn avatar motemen avatar mpeltonen avatar paulbutcher avatar ph2734 avatar philcali avatar pkmx avatar rst avatar rtyley avatar samueltardieu avatar shinichy avatar stevejwriter avatar taku0 avatar timgilbert avatar xuwei-k avatar yasushi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-plugin's Issues

windows compatibility sbt 0.7.x issues

http://groups.google.com/group/simple-build-tool/browse_thread/thread/29fe4de0309cc389

    [info] == AndroidBaby / aapt-generate == 
    java.lang.RuntimeException: Could not parse command: (1,3): Escape sequences 
    can only occur in a quoted argument 
    at scala.Predef$.error(Predef.scala:76) 
    at sbt.Process$.apply(Process.scala:26) 
    at sbt.Process$.apply(Process.scala:15) 
    at sbt.Process$.apply(Process.scala:40) 
    at AndroidProject$$anonfun$aaptGenerateTask$1.apply(AndroidProject.scala:97) 
    at AndroidProject$$anonfun$aaptGenerateTask$1.apply(AndroidProject.scala:97) 
    at sbt.ExecProject$$anonfun$execTask$1.apply(ScalaProject.scala:425) 
    at sbt.ExecProject$$anonfun$execTask$1.apply(ScalaProject.scala:424) 
    at sbt.TaskManager$Task.invoke(TaskManager.scala:62) 
    at sbt.impl.RunTask.doRun$1(RunTask.scala:77) 
    at sbt.impl.RunTask.runTask(RunTask.scala:85) 
    at sbt.impl.RunTask.sbt$impl$RunTask$$runIfNotRoot(RunTask.scala:60) 
    at sbt.impl.RunTask$$anonfun$runTasksExceptRoot$2.apply(RunTask.scala:48) 
    at sbt.impl.RunTask$$anonfun$runTasksExceptRoot$2.apply(RunTask.scala:48) 
    at sbt.Distributor$Run$Worker$$anonfun$2.apply(ParallelRunner.scala:131) 
    at sbt.Distributor$Run$Worker$$anonfun$2.apply(ParallelRunner.scala:131) 
    at sbt.Control$.trapUnit(Control.scala:19) 
    at sbt.Distributor$Run$Worker.run(ParallelRunner.scala:131) 
    [info] == AndroidBaby / aapt-generate ==

Uncouple generated Java sources from regular Java

I am setting up a project to approximate the default Android directory layout and found that aaptGenerateTask outputs to mainJavaSourcePath. If the user wants to add any regular Java files to the project, they will be mixed up in the same directory. This modification fixes that (I believe):

def javaGeneratedSourcePath = "gen"
override def aaptGenerateTask = execTask {<x>
    {aaptPath.absolutePath} package -m -M {androidManifestPath.absolutePath} -S {mainResPath.absolutePath}
       -I {androidJarPath.absolutePath} -J {javaGeneratedSourcePath.absolutePath}
  </x>} dependsOn directory(javaGeneratedSourcePath)

It would be especially useful to distinguish between generated Java files and user-created ones. There might be some build-path problems here (R.java not getting picked up), but if those are fixed, this seems like a cleaner solution.

Proguard making normal testing flow impossible.

We're trying to work with Android/SBT in a test driven way and it is biting us. Right now if you:

  1. write a method called foo that's not referenced else where in your Android project.
  2. write a test for foo code in your test project
  3. run tests, notice failure due to foo being removed by proguard and no longer existing.

I've tried adding various -keep options to proguardOption in my project, but haven't had any luck. Any suggestions for a work around would be highly appreciated.

Building code with annotations+java constants

When adding annotation to a scala class which refer to java constants you get the following error:

App.scala:9: annotation argument needs to be a constant; found: R.string.crash_notif_ticker_text
[error]             resNotifTickerText = R.string.crash_notif_ticker_text,

This is related to https://issues.scala-lang.org/browse/SI-2764. A workaround for now is to add the following to the project definition:

override def compileOrder = CompileOrder.JavaThenScala

We could make this the default for the plugin, but it will slow things down.

TypedResources cause problems in multi-project builds

I have a multi-project sbt build.

When using TypedResources in one of the subprojects, TR.scala is generated in each subproject.

This for example results in a different TR.scala in the test subproject, which in turn prevents the tested application to load due to diverging class definitions ("Class resolved by unexpected DEX", "had used a different ... TypedResource ... during pre-verification").

THIS TOOL IS DEPRECATED.

It gives me "THIS TOOL IS DEPRECATED. See --help for more information" when using sbt start-emulator. Stats:

robospecs_example $ sbt 
[info] Building project RobospecsExample 0.1 against Scala 2.8.1
[info]    using RobospecsExample with sbt 0.7.4 and Scala 2.7.7

PlainJavaProject.settings doesn't actually override manifestPath

Using:

 settings = General.fullAndroidSettings ++ PlainJavaProject.settings

where fullAndroidSettings includes AndroidProject.androidSettings causes sbt to look for AndroidManifest.xml in src/main instead of baseDirectory.

I've tried adding manifestPath := file("AndroidManifest.xml") in various places but to no avail.

Inconsistent format for androidPlatformName

What is the intended format for androidPlatformName?

https://github.com/n8han/android-app.g8 defines it to be android-$api_level$ (i.e. something like android-7). And this makes sense given that:

androidPlatformPath = androidSdkPath / "platforms" / androidPlatformName

But platformName2ApiLevel clearly expects it to be of a different form, for example android-2.1:

  def platformName2ApiLevel:Int = androidPlatformName match {
    case "android-1.0" => 1
    case "android-1.1" => 2
    case "android-1.5" => 3
    case "android-1.6" => 4
    case "android-2.0" => 5
    case "android-2.1" => 7
    case "android-2.2" => 8
    case "android-2.3" => 9
    case "android-2.3.3" => 10
    case "android-3.0" => 11
  }

androidPlatformName is only used if minSdkVersion isn't set. Is the right thing to do to require that minSdkVersion is set and ditch platformName2ApiLevel? Or something else?

TypedView trait ineffective

I noticed this in my code after 0.5.0 went out, the TypedView trait didn't extend TypedViewHolder. Not a big deal since this is probably the least common way to achieve the functionality, and you can still call the method against any by importing the implicit conversion.

Already fixed in master, just documenting the bug here.

Why does each project get its own copy of scala compiler and library

I have created several projects with script/create_project. When I run a command 'sbt update' (or even clean) the first thing it does to to get the scala compiler and then the library. And this takes quite a bit of time. Shouldn't this be done only if the compiler is not present.

downloading http://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.7.7/scala-compiler-2.7.7.jar
downloading http://repo1.maven.org/maven2/org/scala-lang/scala-library/2.7.7/scala-library-2.7.7.jar ...

ProGuard ignores libraries in lib folder

I use one library that is not available via Maven, so I put it in the lib folder of my project.
Compilation of the class files seems to work this way, but the library is apparently not picked up by ProGuard during the compression phase.
When running the application on the phone, consequently, I get an exception saying that a class contained in the library could not be found.

Is there a way to specify that jars in the lib folder should be picked up by ProGuard?

Thanks!

PS: I use sbt 0.11 and the sbt_011 of the android-plugin.

Java+Scala Project: Object app is not a member of package

I successfully built the Scala-only project template. Next, I tried to add some Java sources to my project and got the following error in TR.scala.

Any ideas what could be the cause? (it seems to me like sbt can't find the Android libraries now that I added Java sources for some reason.)

[info] Compiling 2 Scala sources and 5 Java sources to D:\Workspaces\MyProject\my-project\target\scala-2.9.0-1\classes...
[error] D:\Workspaces\MyProject\my-project\target\src_managed\main\scala\com\mydomain\myproject\TR.scala:2: object app is not a member of package com.mydomain.myproject.android
[error] import android.app.Activity
[error] ^
[error] D:\Workspaces\MyProject\my-project\target\src_managed\main\scala\com\mydomain\myproject\TR.scala:3: object view is not a member of package com.mydomain.myproject.android
[error] import android.view.View
[error] ^
[error] two errors found
[error] {file:/D:/Workspaces/MyProject/my-project/}My Project/compile:compile: Compilation failed
[error] Total time: 5 s, completed Oct 12, 2011 11:20:55 AM

tests project from setup script isn't working

I created a project with the "create_project" command. The Hello World Application works fine but the tests project doesn't work.

> android-plugin/script/create_project cleanProject com.example
> cd cleanProject/
> sbt
> update
> package-debug
> start-emulator // => works fine

> project tests
> test-emulator => Error

[info] android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests:
[info] Error in testSuiteConstructionFailed:
[info] java.lang.RuntimeException: Exception during suite construction
[info]  at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:239)
[info]  at java.lang.reflect.Method.invokeNative(Native Method)
[info]  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
[info]  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
[info]  at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:520)
[info]  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
[info] Caused by: java.lang.TypeNotPresentException: Type java.rmi.RemoteException not present
[info]  at java.lang.Class.getDeclaredMethods(Native Method)
[info]  at java.lang.ClassCache.getDeclaredPublicMethods(ClassCache.java:166)
[info]  at java.lang.ClassCache.getDeclaredMethods(ClassCache.java:179)
[info]  at java.lang.ClassCache.findAllMethods(ClassCache.java:249)
[info]  at java.lang.ClassCache.getFullListOfMethods(ClassCache.java:223)
[info]  at java.lang.ClassCache.getAllPublicMethods(ClassCache.java:204)
[info]  at java.lang.Class.getMethods(Class.java:1015)
[info]  at android.test.suitebuilder.TestGrouping.getTestMethods(TestGrouping.java:79)
[info]  at android.test.suitebuilder.TestGrouping.getTests(TestGrouping.java:71)
[info]  at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:183)
[info]  at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:373)
[info]  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4218)
[info]  at android.app.ActivityThread.access$3000(ActivityThread.java:125)
[info]  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
[info]  at android.os.Handler.dispatchMessage(Handler.java:99)
[info]  at android.os.Looper.loop(Looper.java:123)
[info]  at android.app.ActivityThread.main(ActivityThread.java:4627)
[info]  at java.lang.reflect.Method.invokeNative(Native Method)
[info]  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
[info]  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
[info]  at dalvik.system.NativeStart.main(Native Method)

API Level 10 support

I've set this in my project/build/MyProject.scala:
trait Defaults {
def androidPlatformName = "android-10"
}

Which seems to work fine. However, I had a look at the source of android-plugin and found that it doesn't support API level 10 in AndroidProject.platformName2ApiLevel. It also seems that platformName2ApiLevel expects another format, e.g. android-2.2 instead of android-8. Perhaps it would make sense to use one format throughout?

Class Not Found Error when using intent Receiver

When I build everything with Ant and http://code.google.com/p/scalaforandroid/ everything works fine, but when I build my project with sbt/android-plugin Android throws an exception on boot when looking for my BroadcastReceiver subclass. Launching the app through the main activity still works fine, just this broadcast receiver class is not found.

My BroadcastReceiver is simple:

class CoreReceiver extends BroadcastReceiver {
  val BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED"

  override def onReceive(context: Context, intent: Intent) {
     if (intent.getAction().equals(BOOT_COMPLETED)) {
       // Do something
    }
  }
}

and I have the following in my AndroidManifest:

  <receiver android:name="CoreReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
  </receiver>

Classes in external JARs doesn't show up in the APK.

I had this problem when trying to add an external JAR library into my project's 'lib' directory. The 'android:package-debug' task goes fine but when the app starts, ClassNotFoundExceptions is reported. Robert Thau ([email protected]) solved this problem by adding the JARs from the 'lib' directory into proguardInJars, I, however, have preinstalled the Scala libraries on the device so the proguard task is skipped in my case. Quoting Robert Thau: "I'm not sure it was a deliberate change, but I don't recall this sort of thing being necessary in the 0.7 version of the plugin..."

Discussion on Google Groups: http://groups.google.com/group/scala-on-android/browse_thread/thread/2219fc6b6b17690c

Use giter8 for project creation

Make sure that everything the scripts do is available from a giter8 template (there are already two, gseitz/android-sbt-project and charroch/android, may want to fork one) and then remove the scripts and update the readme.

useProguard = false in version 0.60 and sbt 0.11 ?

Hi,
I was wondering how one would go about to set useProguard to false in V 0.60 and sbt 0.11 ? I noticed the default is true in AndroidBase, but my attempts to override it were all unsuccessful (other than setting the value directly and repackaging the plugin).

Thanks

Unresolved dependency when creating application

See this Stack Overflow post.

[info] Loading project definition from /Users/macarse/Documents/scalatest/project/plugins
[info] Updating {file:/Users/macarse/Documents/scalatest/project/plugins/}default-dd299a...
[warn] module not found: org.scala-tools.sbt#sbt-android-plugin_2.9.1;0.6.0-SNAPSHOT
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-android-plugin_2.9.1/0.6.0-SNAPSHOT/ivys/ivy.xml
[warn] -- artifact org.scala-tools.sbt#sbt-android-plugin_2.9.1;0.6.0-SNAPSHOT!sbt-android-plugin_2.9.1.jar:
[warn] http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-android-plugin_2.9.1/0.6.0-SNAPSHOT/jars/sbt-android-plugin_2.9.1.jar
[warn] ==== local: tried
[warn] /Users/macarse/.ivy2/local/org.scala-tools.sbt/sbt-android-plugin_2.9.1/0.6.0-SNAPSHOT/ivys/ivy.xml
[warn] -- artifact org.scala-tools.sbt#sbt-android-plugin_2.9.1;0.6.0-SNAPSHOT!sbt-android-plugin_2.9.1.jar:
[warn] /Users/macarse/.ivy2/local/org.scala-tools.sbt/sbt-android-plugin_2.9.1/0.6.0-SNAPSHOT/jars/sbt-android-plugin_2.9.1.jar
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt-android-plugin_2.9.1/0.6.0-SNAPSHOT/sbt-android-plugin_2.9.1-0.6.0-SNAPSHOT.pom
[warn] -- artifact org.scala-tools.sbt#sbt-android-plugin_2.9.1;0.6.0-SNAPSHOT!sbt-android-plugin_2.9.1.jar:
[warn] http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt-android-plugin_2.9.1/0.6.0-SNAPSHOT/sbt-android-plugin_2.9.1-0.6.0-SNAPSHOT.jar
[warn] ==== Scala-Tools Maven2 Repository: tried
[warn] http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt-android-plugin_2.9.1/0.6.0-SNAPSHOT/sbt-android-plugin_2.9.1-0.6.0-SNAPSHOT.pom
[warn] -- artifact org.scala-tools.sbt#sbt-android-plugin_2.9.1;0.6.0-SNAPSHOT!sbt-android-plugin_2.9.1.jar:
[warn] http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt-android-plugin_2.9.1/0.6.0-SNAPSHOT/sbt-android-plugin_2.9.1-0.6.0-SNAPSHOT.jar
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scala-tools.sbt#sbt-android-plugin_2.9.1;0.6.0-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[error] {file:/Users/macarse/Documents/scalatest/project/plugins/}default-dd299a/*:update: sbt.ResolveException: unresolved dependency: org.scala-tools.sbt#sbt-android-plugin_2.9.1;0.6.0-SNAPSHOT: not found
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

Alternative for using the apkbuilder command line tool

When I execute "package-debug", the final step shows a message (logged as error, but is actually just a warning):

[debug] Executing command [//android-sdk-linux_86/tools/apkbuilder, /tmp/android_scala/target/scala_2.8.1/dsc_test_2.8.1-1.0.apk, -z, /tmp/android_scala/target/scala_2.8.1/resources.apk, -f, /tmp/android_scala/target/scala_2.8.1/classes.dex]
[error] 
[error] THIS TOOL IS DEPRECATED. See --help for more information.
[error] 
[info] == package-debug ==
[success] Successful.
[info] 

When I run apkbuilder from the command line, this message is shown:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
THIS TOOL IS DEPRECATED and may stop working at any time!

If you wish to use apkbuilder for a custom build system, please look at the
com.android.sdklib.build.ApkBuilder which provides support for
recent build improvements including library projects.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Exception in thread "main" java.lang.VerifyError

When I try to use the script to create a project, I get:

jamesmoore@james-moores-macbook-pro-2:/tmp$ ~/dev/android-plugin/script/create_project MyAndroidProject com.banshee.project
Exception in thread "main" java.lang.VerifyError: (class: scala/tools/nsc/MainGenericRunner$, method: main signature: ([Ljava/lang/String;)V) Can only throw Throwable objects
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
jamesmoore@james-moores-macbook-pro-2:/tmp$

I'm using ee96247

Java resources in jars are omitted from apk

For my project I'm using some 'standard' java JARs (apache sshd). Those jars include various property files which are eventually read using getResource() or getResourceAsStream(). Android properly looks in the apk for these files, but apkBuilder by default does not propagate them. Historically ant would pass in --rp to apkBuilder so these resources would get included.

I think sbt should invoke apkBuilder.addResourcesFromJar and pass in the post proguard jar. This would allow sbt to behave similarly to java android projects, where users pass in "-keeppackagenames org.apache.sshd" to proguard, and then the downstream Android tools do the right thing.

I've made this fix and will submit a pull request shortly...

(Delete me)

Sorry, I didn't realize that submitting a pull request creates an issue.

"[error] File name too long" when running sbt to build android-plugin

When I run sbt to build android-plugin, it fails with:

schmichael@drventure:~/src/android-plugin$ sbt publish-local
[info] 
[info] Updating plugins...
[info] :: retrieving :: plugin-definition#plugin-definition_2.7.7 [sync]
[info]  confs: [compile, runtime, test, provided, system, optional, sources, javadoc]
[info]  0 artifacts copied, 10 already retrieved (0kB/36ms)
[success] Plugins updated successfully.
[info] 
[info]  Extracted source plugin ./lib_managed/scala_2.7.7/sxr-publish-0.1.6.jar ...
[info]  Extracted source plugin ./lib_managed/scala_2.7.7/posterous-sbt-0.1.4.jar ...
[info] Recompiling plugin...
[info]    Source analysis: 2 new/modified, 0 indirectly invalidated, 0 removed.
[error] File name too long
[error] one error found
Compilation failed

Hit enter to retry or 'exit' to quit: 

The root path of my android-plugin clone:

/home/schmichael/src/android-plugin

Using:

  • Ubuntu 10.04 Lucid
  • Sun Java 6.20
  • sbt 0.7.4
  • scala 2.7.7

InvocationTargetException running android:package-debug

I've followed the instructions on the main page to build the android-plugin and create a project using the giter8 template. When I run "android:package-debug" I get an InvocationTargetException. I am using SBT 0.11, trunk of the android-plugin (5abe8be), and Android SDK version 10.

This is the error output:

$ sbt
[info] Loading project definition from /private/tmp/test/project/plugins
[info] Updating {file:/private/tmp/test/project/plugins/}default-667ad5...
[info] Done updating.
[info] Compiling 1 Scala source to /private/tmp/test/project/target/scala_2.9.1/classes...
[info] Set current project to Test (in build file:/private/tmp/test/)

android:package-debug
[info] Wrote /private/tmp/test/target/src_managed/main/scala/test/TR.scala
[info] Updating {file:/private/tmp/test/}Test...
[info] Done updating.
[info] Compiling 2 Scala sources and 1 Java source to /private/tmp/test/target/scala-2.9.0-1/classes...
ProGuard, version 4.4
ProGuard is released under the GNU General Public License. The authors of all
programs or plugins that link to it (sbt, scala, ...) therefore
must ensure that these programs carry the GNU General Public License as well.
Reading program directory [/private/tmp/test/target/scala-2.9.0-1/classes]
Reading program jar /tmp/.sbt/boot/scala-2.9.0-1/lib/scala-library.jar
Reading library jar [/tmp/projects/tools/android-sdk-mac_x86-13/platforms/android-10/android.jar]
Note: You're ignoring all warnings!
Preparing output jar [/private/tmp/test/target/classes.min.jar]
Copying resources from program directory [/private/tmp/test/target/scala-2.9.0-1/classes]
Copying resources from program jar /tmp/.sbt/boot/scala-2.9.0-1/lib/scala-library.jar
[info] Dexing /private/tmp/test/target/classes.dex
[error] {file:/private/tmp/test/}Test/android:package-debug: java.lang.reflect.InvocationTargetException
[error] Total time: 89 s, completed ....

Issues with TypedResouces

See: http://gist.github.com/543295

There are two separate issues here.

  1. The import issue. I'm using root.com.android everywhere with no issues, but honestly I'm not sure what would cause errors like this, it seems like there would have to be something else in my class path.
  2. The R.id.android:list issue. This looks like a bug. I'm think one solution would be to just ignore R.id.android*, but list might be the only special case.

I'll put together a patch soon and see how things go.

Proguard is not using the build version of the scala library

I am the guy who wrote the original AndroidProject. Thanks for a job well done!

I am using xsbt 0.6.10 with android-plugin and encountered an issue when building against scala-2.8.0.Beta1-RC7. Because xsbt is compiled in scala-2.7.7 but builds using scala-2.8.0, the injars parameter in the proguard task should include 2.8.0 scala-library instead of 2.7.7.

Below is the my patch:
diff --git a/src/main/scala/AndroidProject.scala b/src/main/scala/AndroidProject.scala
index 493c37c..40d587a 100644
--- a/src/main/scala/AndroidProject.scala
+++ b/src/main/scala/AndroidProject.scala
@@ -114,7 +114,7 @@ abstract class AndroidProject(info: ProjectInfo) extends DefaultProject(info) {
def proguardAction = proguardTask dependsOn(compile) describedAs("Optimize class files.")
def proguardTask = task {
val args = "-injars" :: mainCompilePath.absolutePath+File.pathSeparator+

  •                         FileUtilities.scalaLibraryJar.getAbsolutePath+"(!META-INF/MANIFEST.MF,!library.properties)"+
    
  •                         buildScalaInstance.libraryJar.getAbsolutePath+"(!META-INF/MANIFEST.MF,!library.properties)"+
                          (if (!proguardInJars.getPaths.isEmpty) File.pathSeparator+proguardInJars.getPaths.map(_+"(!META-INF/MANIFEST.MF)").mkString(File.pathSeparator) else "") ::  
            "-outjars" :: classesMinJarPath.absolutePath ::
            "-libraryjars" :: libraryJarPath.getPaths.mkString(File.pathSeparator) :: 
    

start-device and related actions don't work with devices connected via TCP

android-plugin 0.5.1 only allows for running commands on "the emulator" (adb -e) or on "the device" (adb -d). When a device is connected via TCP instead of USB, it is not found by "adb -d":

[info] == My Android Project / reinstall-device ==
[debug] Executing command [/Users/kneissl/android-sdk/platform-tools/adb, -d, install, -r, /Users/kneissl/tmp/my-android-project/target/scala_2.8.1/my-android-project_2.8.1-0.1.apk]
[error] error: device not found

add start action

am start -a android.intent.action.MAIN -n com.example/com.example.Foo

Problem with whitespace in ivy-repo path

I have a android project with one library dependency.

My local ivy-repo is in the windows home folder (C:\Documents and
Settings ...)

It looks like the android plugin has some problems with the
whitespaces in the path when doing android:package-debug:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: C:\Documents: file not found
at com.android.dx.util.FileUtils.readFile(FileUtils.java:55)
at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:
133)
at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:
108)
at com.android.dx.command.dexer.Main.processOne(Main.java:313)
at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:
233)
at com.android.dx.command.dexer.Main.run(Main.java:185)
at com.android.dx.command.dexer.Main.main(Main.java:166)
at com.android.dx.command.Main.main(Main.java:90)

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: and: file not found
at com.android.dx.util.FileUtils.readFile(FileUtils.java:55)
at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:
133)
at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:
108)
at com.android.dx.command.dexer.Main.processOne(Main.java:313)
at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:
233)
at com.android.dx.command.dexer.Main.run(Main.java:185)
at com.android.dx.command.dexer.Main.main(Main.java:166)
at com.android.dx.command.Main.main(Main.java:90)

UNEXPECTED TOP-LEVEL EXCEPTION:
java.io.FileNotFoundException: Settings\user.ivy2\cache
\com.google.protobuf\protobuf-java\jars\protobuf-java-2.4.1.jar (The
system cannot find th
e path specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:127)
at java.util.zip.ZipFile.(ZipFile.java:144)
at
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:
205)
at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:
130)
at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:
108)
at com.android.dx.command.dexer.Main.processOne(Main.java:313)
at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:
233)
at com.android.dx.command.dexer.Main.run(Main.java:185)
at com.android.dx.command.dexer.Main.main(Main.java:166)
at com.android.dx.command.Main.main(Main.java:90)

How to specify alternate proguard configuration?

I am not well versed with SBT plugins, or even with SBT for that matter.

How can I instruct the proguard task to use an external configuration file?

From a cursory glance it looks like the proguard task has all the command line parameters specified in the task definition itself.

building error with gr8 template

When I created a project with gr8 template and up-to-date master branch, I get

[error] missing arguments for method ++ in trait TraversableLike;
[error] follow this method with `_' if you want to treat it as a partially applied function
[error] TypedResources.settings ++

in build.scala

Correct README.markdown

In the README.markdown it should read
import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val android = "org.scala-tools.sbt" % "sbt-android-plugin" % "0.4.1"
}
instead of
import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val android = "org.scala-tools.sbt" % "android-plugin" % "0.4.1"
}

should -keep subclasses of android.content.ContentProvider

Proguard is stripping my ContentProvider implementor from the generated jar / apk. It looks like adding the following should work, but it doesn't seem to help:

"-keep public class * extents android.content.ContentProvider" ::

(in AndroidProject.scala, alongside all the other -keep flags)

Proguard strips classes mentioned in XML layout.

This may be a tricky one, but I suspect that it is not possible to use custom classes in XML layouts as proguard will not recognise the reference. Perhaps the plugin should parse classnames from XML layouts and pass these to proguard as keepers.

e.g.

The XML layout includes reference to net.badgerhunt.hwa.ScribbleView

The full jar...

jar tvf target/scala_2.7.7/hwandroidproject_2.7.7-0.1.jar 
    25 Wed May 12 14:44:38 EST 2010 META-INF/MANIFEST.MF
   320 Wed May 12 14:44:36 EST 2010 net/badgerhunt/hwa/R$string.class
   464 Wed May 12 14:44:36 EST 2010 net/badgerhunt/hwa/R.class
   324 Wed May 12 14:44:36 EST 2010 net/badgerhunt/hwa/R$drawable.class
   991 Wed May 12 14:44:34 EST 2010 net/badgerhunt/hwa/MainActivity.class
   264 Wed May 12 14:44:36 EST 2010 net/badgerhunt/hwa/R$attr.class
   316 Wed May 12 14:44:36 EST 2010 net/badgerhunt/hwa/R$layout.class
  1835 Wed May 12 14:27:42 EST 2010 net/badgerhunt/hwa/ScribbleView.class
   477 Wed May 12 14:44:36 EST 2010 net/badgerhunt/hwa/R$id.class

The minimum jar ...

jar tvf target/scala_2.7.7/classes.min.jar 
   793 Wed May 12 14:44:56 EST 2010 net/badgerhunt/hwa/MainActivity.class
   316 Wed May 12 14:44:56 EST 2010 net/badgerhunt/hwa/R$layout.class
   272 Wed May 12 14:44:56 EST 2010 net/badgerhunt/hwa/R.class

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.