clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

Either used the most recent dx or allow user to specify which build-tools #89

Closed kenrestivo closed 10 years ago

kenrestivo commented 10 years ago

It'd be nice if create-dx could use the most recent build-tools on the system, or let the user specify which one (i.e. to get around bugs in 17.0.0 that are fixed in 19.0.3). See https://github.com/clojure-android/neko/issues/29

alexander-yakushev commented 10 years ago

OK, right now it just gets the first directory under build-tools/. The problem was that the naming of those inside directories was not consistent before, I remember mine being called android-4.2 while on other setups it was 17.0.0. Right now hopefully the names are just SDK tools versions. So probably two things can be done (and I mean both of them):

Do you think this will do?

kenrestivo commented 10 years ago

That'd be perfect, thanks!

alexander-yakushev commented 10 years ago

OK, done and done, please see 0.2.3-SNAPSHOT version. If everything is OK I will cut a minor release.

kenrestivo commented 10 years ago
-*- mode: compilation; default-directory: "/home/footest/" -*-
Compilation started at Tue Apr 15 22:26:49

DEBUG=1 lein droid create-dex
Leiningen's classpath: :/home/lken/.lein/self-installs/leiningen-2.3.4-standalone.jar
Applying task droid to (create-dex)
java.lang.Exception: Error loading /home/unlogic/clojure/android/splashtest/project.clj
    at leiningen.core.project$read$fn__3326.invoke(project.clj:696)
    at leiningen.core.project$read.invoke(project.clj:693)
    at leiningen.core.project$read.invoke(project.clj:703)
    at leiningen.droid.utils$read_project.invoke(utils.clj:141)
    at leiningen.droid.utils$proj.invoke(utils.clj:189)
    at leiningen.droid$droid.doInvoke(droid.clj:89)
    at clojure.lang.RestFn.invoke(RestFn.java:423)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.core.main$resolve_task$fn__3029.doInvoke(main.clj:189)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.core.main$apply_task.invoke(main.clj:230)
    at leiningen.core.main$resolve_and_apply.invoke(main.clj:234)
    at leiningen.core.main$_main$fn__3092.invoke(main.clj:303)
    at leiningen.core.main$_main.doInvoke(main.clj:290)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.core$apply.invoke(core.clj:617)
    at clojure.main$main_opt.invoke(main.clj:335)
    at clojure.main$main.doInvoke(main.clj:440)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at clojure.lang.Var.invoke(Var.java:427)
    at clojure.lang.AFn.applyToHelper(AFn.java:172)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)
Caused by: java.io.FileNotFoundException: /home/unlogic/clojure/android/splashtest/project.clj (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:97)
    at clojure.lang.Compiler.loadFile(Compiler.java:7017)
    at clojure.lang.RT$3.invoke(RT.java:318)
    at leiningen.core.project$read$fn__3326.invoke(project.clj:694)
    ... 31 more

Compilation exited abnormally with code 1 at Tue Apr 15 22:26:51
alexander-yakushev commented 10 years ago

Damn, forgot to remove debugging code, sorry. Should work now, try to remove 0.2.3-SPLASHTEST from ~/.m2/repository/lein-droid and run again.

alexander-yakushev commented 10 years ago

I took the courage to push 0.2.3 before your response. I will close the issue as soon as you approve.

kenrestivo commented 10 years ago

Sorry for the long delay.

0.2.3 is definitely an improvement. With 0.2.3, and three different versions of build-tools present (17.0.0, 19.0.1, and 19.0.3), running create-dex chose to use 19.0.1 instead of 17.0.0

-*- mode: compilation; default-directory: "/home/foo/src/foo/" -*-
Compilation started at Thu Apr 17 11:12:57

DEBUG=1 lein with-profile droid droid create-dex
Leiningen's classpath: :/home/lken/.lein/self-installs/leiningen-2.3.4-standalone.jar
Applying task with-profile to (droid droid create-dex)
Applying task droid to (create-dex)
Warning: profile :android-dev not found.
Creating DEX....
/usr/local/android/sdk-linux_x86/build-tools/19.0.1/dx -JXmx4096M --dex --no-optimize --output /home/foo/src/foo/target/classes.dex /home/foo/src/foo/target/classes /usr/local/android/sdk-linux_x86/tools/support/annotations.jar /home/lken/.m2/repository/neko/neko/3.0.0/neko-3.0.0.jar /home/lken/.m2/repository/utilza/utilza/0.1.53/utilza-0.1.53.jar /home/lken/.m2/repository/org/clojure-android/clojure/1.5.1-jb/clojure-1.5.1-jb.jar /home/lken/.m2/repository/org/timmc/handy/1.5.0/handy-1.5.0.jar /home/lken/.m2/repository/cheshire/cheshire/5.3.0/cheshire-5.3.0.jar /home/lken/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.3.0/jackson-core-2.3.0.jar /home/lken/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-smile/2.3.0/jackson-dataformat-smile-2.3.0.jar /home/lken/.m2/repository/tigris/tigris/0.1.1/tigris-0.1.1.jar /usr/local/android/sdk-linux_x86/extras/android/support/v4/android-support-v4.jar

Compilation finished at Thu Apr 17 11:13:13

However, it didn't choose 19.0.3, so, not quite right yet. But at least the dex no longer fails to include important classes because of using the too-old 17.0.0.

alexander-yakushev commented 10 years ago

Oh well. For some reason I thought that File.list() method sorts the entries automatically. Apparently it doesn't. I pushed a fix for this. Thank you so much for your help:)

alexander-yakushev commented 10 years ago

Do you think we can close it now, Ken?

kenrestivo commented 10 years ago

Absolutely, I thought it had been already. Thanks!