jberkel / android-plugin Goto Github PK
View Code? Open in Web Editor NEWAn sbt plugin for Android development in Scala
Home Page: https://groups.google.com/forum/#!forum/scala-on-android
License: Other
An sbt plugin for Android development in Scala
Home Page: https://groups.google.com/forum/#!forum/scala-on-android
License: Other
To reproduce:
Observe that only the default sbt actions get listed.
change setup line https://github.com/n8han/conscript/raw/master/setup.sh to
https://raw.github.com/n8han/conscript/master/setup.sh
github must have changed the way they expose raw.
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
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>
It seems better for these to be in target/ somewhere.
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.
First I was running into OOM issues when running dx on my test project, now it gets through it, but fails with the message:
trouble writing output: format == null
which is explained here http://code.google.com/p/android/issues/detail?id=7147
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) ::
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 ....
It seems to be possible to set up the emulator with a shared copy of the Scala libraries:
http://lamp.epfl.ch/~michelou/android/emulator-android-sdk.html
When the emulator has been set up in this way, the ProGuard step could be skipped (it's rather slow).
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
am start -a android.intent.action.MAIN -n com.example/com.example.Foo
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...
releated to GH-24
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 ==
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"
}
See: http://gist.github.com/543295
There are two separate issues here.
I'll put together a patch soon and see how things go.
The line:
val android = "org.scala-tools.sbt" % "sbt-android-plugin" % "0.5.0"
in the file android-plugin\script\create_project
Should be updated to version 0.5.1 as this is the current version
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)
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?
We're trying to work with Android/SBT in a test driven way and it is biting us. Right now if you:
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.
I don't seem to have it in my project or indeed anywhere in the checked-out source code (except in the readme file)
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)
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
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.
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
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").
single project / multiproject, no specs, no tests, no activity etc.
Hi, I'm using the plugin from the master branch and I've added 'useProguard in Android := false'. The problem is 'android:package-debug' won't package my changes into the apk unless I do a 'clean' first. I'm not sure this has anything to do with the proguard change. A similar problem is reported here: http://groups.google.com/group/scala-on-android/browse_thread/thread/83689bc18073d5ce
Sorry, I didn't realize that submitting a pull request creates an issue.
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
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?
The adb tool has moved to platform-tools directory from tools.
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.
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 ...
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?
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
The wiki shows this command:
curl https:/raw.github.com/n8han/conscript/master/setup.sh | sh
Could you correct it to write:
curl https://raw.github.com/n8han/conscript/master/setup.sh | sh
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.
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)
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
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:
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.
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.
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.
It would be handy to have a Task included with the android-plugin that could dex and install scala to the emulator.
http://zegoggl.es/2011/07/how-to-preinstall-scala-on-your-android-phone.html
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.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.