clojure-android / lein-droid

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

failed to lein droid build #32

Closed jukworks closed 11 years ago

jukworks commented 11 years ago

Hi,

I'm trying a lein-droid on Windows 7 64-bit.

lein droid new clojuroid kr.ac.ajou.dv.clojuroid :activity MainActivity :target-sdk 10 :app-name ClojureMeetsAndroid

and

lein deps

worked fine.

When I tried lein droid build, it fails...

I used a Cygwin shell, and the error message follows: Unfortunately, DEBUG=1 did not show me a meaningful message. Just a NullPointerException.

$ DEBUG=1 lein droid build Leiningen's classpath: ;C:\cygwin\home\yu4up.lein/self-installs/leiningen-2.1.3-standalone.jar Applying task droid to (build) Generating R.java... java.lang.NullPointerException at clojure.java.io$as_relative_path.invoke(io.clj:403) at clojure.java.io$file.invoke(io.clj:415) at clojure.lang.ArrayChunk.reduce(ArrayChunk.java:58) at clojure.core.protocols$fn6041.invoke(protocols.clj:98) at clojure.core.protocols$fn6005$G60006014.invoke(protocols.clj:19) at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31) at clojure.core.protocols$fn6028.invoke(protocols.clj:48) at clojure.core.protocols$fn5979$G59745992.invoke(protocols.clj:13) at clojure.core$reduce.invoke(core.clj:6177) at clojure.java.io$file.doInvoke(io.clj:417) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:619) at leiningen.droid.utils$sdk_binary.invoke(utils.clj:39) at leiningen.droid.compile$code_gen.invoke(compile.clj:26) at leiningen.droid.build$build.invoke(build.clj:82) at leiningen.droid$execute_subtask.invoke(droid.clj:103) at leiningen.droid$droid.doInvoke(droid.clj:74) 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$fn1836.doInvoke(main.clj:149) 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:189) at leiningen.core.main$resolve_and_apply.invoke(main.clj:193) at leiningen.core.main$_main$fn1899.invoke(main.clj:257) at leiningen.core.main$_main.doInvoke(main.clj:247) 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)

My .profiles.clj

{:user {:plugins [[lein-droid "0.1.0-preview5"]]} :android {:sdk-path "C:\Users\yu4up\AppData\Local\Android\android-sdk"} }

And I didn't edit the project.clj.

Thank you, Jonguk Kim

jukworks commented 11 years ago

Same issue on my Ubuntu 13.04 64-bit.

If I change to the version 0.1.0-preview3 or 4, it doesn't emit NullPointerException, but it complains there's no aapt. I saw the issue for that. So, I think I'd better wait for fixing preview5.

Thank you.

alexander-yakushev commented 11 years ago

Damn, I always forget to update that file, sorry:-(. preview5 is already there, you can go try if it works for you. Also please make sure you use neko 2.0.0-beta3 version as a dependency.

jukworks commented 11 years ago

I tried with preview5 and neko 2.0.0-beta3, but it fails again with the same error messages.

Could you give me a hint?

$ cat ~/.lein/profiles.clj {:user {:plugins [[lein-droid "0.1.0-preview5"]]} :android {:sdk-path "/home/j0nguk/android-sdk-linux"}}

$ cat ~/.lein/profiles.clj {:user {:plugins [[lein-droid "0.1.0-preview5"]]} :android {:sdk-path "/home/j0nguk/android-sdk-linux"}}

$ cat project.clj (defproject clojuroid/clojuroid "0.0.1-SNAPSHOT" :description "FIXME: Android project description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :min-lein-version "2.0.0"

:warn-on-reflection true

:source-paths ["src/clojure"] :java-source-paths ["src/java" "gen"] ;; The following two definitions are optional. The default ;; target-path is "target", but you can change it to whatever you like. ;; :target-path "bin" ;; :compile-path "bin/classes"

;; Uncomment this line if your project doesn't use Clojure. Also ;; don't forget to remove respective dependencies. ;; java-only true

:dependencies [[android/clojure "1.4.0"] [neko/neko "2.0.0-beta3"]] :profiles {:dev {:dependencies [[android/tools.nrepl "0.2.0-bigstack"]] :android {:aot :all-with-unused}} :release {:android {;; Specify the path to your private ;; keystore and the the alias of the ;; key you want to sign APKs with. ;; :keystore-path "/home/user/.android/private.keystore" ;; :key-alias "mykeyalias" :aot :all}}}

:android {;; Specify the path to the Android SDK directory either ;; here or in your ~/.lein/profiles.clj file. ;; :sdk-path "/home/user/path/to/android-sdk/"

        ;; Uncomment this if dexer fails with OutOfMemoryException
        ;; :force-dex-optimize true

        :target-version "10"
        :aot-exclude-ns ["clojure.parallel"]})

$ DEBUG=1 lein droid doall Leiningen's classpath: :/home/j0nguk/.lein/self-installs/leiningen-2.1.3-standalone.jar Applying task droid to (doall) Generating R.java... java.lang.NullPointerException at clojure.java.io$as_relative_path.invoke(io.clj:403) at clojure.java.io$file.invoke(io.clj:415) at clojure.lang.ArrayChunk.reduce(ArrayChunk.java:58) at clojure.core.protocols$fn6041.invoke(protocols.clj:98) at clojure.core.protocols$fn6005$G60006014.invoke(protocols.clj:19) at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31) at clojure.core.protocols$fn6028.invoke(protocols.clj:48) at clojure.core.protocols$fn5979$G59745992.invoke(protocols.clj:13) at clojure.core$reduce.invoke(core.clj:6177) at clojure.java.io$file.doInvoke(io.clj:417) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:619) at leiningen.droid.utils$sdk_binary.invoke(utils.clj:39) at leiningen.droid.compile$code_gen.invoke(compile.clj:26) at leiningen.droid.build$build.invoke(build.clj:82) at leiningen.droid$doall.doInvoke(droid.clj:36) at clojure.lang.RestFn.invoke(RestFn.java:410) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.RestFn.applyTo(RestFn.java:132) at clojure.core$apply.invoke(core.clj:619) at leiningen.droid$execute_subtask.invoke(droid.clj:106) at leiningen.droid$droid.doInvoke(droid.clj:74) 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$fn1836.doInvoke(main.clj:149) 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:189) at leiningen.core.main$resolve_and_apply.invoke(main.clj:193) at leiningen.core.main$_main$fn1899.invoke(main.clj:257) at leiningen.core.main$_main.doInvoke(main.clj:247) 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)

alexander-yakushev commented 11 years ago

Oh well. I forgot to tell that you have to update to the latest Android SDK Tools version, specifically you have to install Android SDK Build-tools 17.0.0. They introduced some breaking changes with this version, I've updated lein-droid to fit it, but now it doesn't work with older versions.

I'm sorry again. I will update the README now.

jukworks commented 11 years ago

Thank you for a quick reply. I know the big change of Android rev 17. I have that version. I tried with openjdk6, openjdk7, and oracle-java6 (update 45), but all of them failed. Could you give me any other hint?

alexander-yakushev commented 11 years ago

Could you please tell the contents of your $ANDROID_SDK/build-tools directory? There should be exactly one directory there, although I'm not sure (there is no documentation on this from Google:( ).

jukworks commented 11 years ago

$ echo $ANDROID_SDK /home/j0nguk/android-sdk-linux

$ ls /home/j0nguk/android-sdk-linux/build-tools/ 17.0.0

$ uname -a Linux jongukim-dvlab 3.8.0-22-generic #33-Ubuntu SMP Thu May 16 15:17:14 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Thank you.

alexander-yakushev commented 11 years ago

Well, I'm certain the problem is that lein-droid cannot find that 17.0.0 directory, but I'm running out of ideas why.

Could you please fire up a REPL on your machine and execute the following:

(require 'clojure.java.io)
(seq (.list (clojure.java.io/file "/home/j0nguk/android-sdk-linux/build-tools")))

And tell what you get. It might be something about access permissions or something, but still unlikely...

jukworks commented 11 years ago

Thank you for your kind answer.

REPL complains a lot. I don't know why. Running REPL in another leiningen project does not show any warnings.

I executed commands you requested.

Jonguk Kim

$ lein repl Reflection warning, clojure/tools/nrepl/bencode.clj:152 - reference to field byteValue can't be resolved. Reflection warning, clojure/tools/nrepl/bencode.clj:152 - call to valueOf can't be resolved. Reflection warning, clojure/tools/nrepl/misc.clj:17 - reference to field printStackTrace can't be resolved. Reflection warning, clojure/tools/nrepl.clj:185 - reference to field getPort can't be resolved. Reflection warning, clojure/tools/nrepl.clj:186 - reference to field getHost can't be resolved. Reflection warning, clojure/tools/nrepl.clj:190 - reference to field getScheme can't be resolved. Reflection warning, clojure/tools/nrepl.clj:190 - reference to field toLowerCase can't be resolved. Reflection warning, clojure/tools/nrepl/ack.clj:47 - reference to field close can't be resolved. Reflection warning, clojure/tools/nrepl/middleware/interruptible_eval.clj:104 - call to java.util.concurrent.ThreadPoolExecutor ctor can't be resolved. Reflection warning, clojure/tools/nrepl/middleware/interruptible_eval.clj:128 - call to execute can't be resolved. Reflection warning, clojure/tools/nrepl/middleware/interruptible_eval.clj:146 - call to execute can't be resolved. Reflection warning, clojure/tools/nrepl/middleware/session.clj:37 - call to append can't be resolved. Reflection warning, clojure/tools/nrepl/middleware/session.clj:38 - call to append can't be resolved. Reflection warning, clojure/tools/nrepl/middleware/session.clj:182 - call to write can't be resolved. Reflection warning, clojure/tools/nrepl/server.clj:33 - reference to field close can't be resolved. Reflection warning, clojure/tools/nrepl/server.clj:85 - call to java.net.InetSocketAddress ctor can't be resolved. Reflection warning, complete/core.clj:38 - reference to field getName can't be resolved. Reflection warning, complete/core.clj:38 - reference to field getName can't be resolved. Reflection warning, complete/core.clj:37 - reference to field getMethods can't be resolved. Reflection warning, complete/core.clj:44 - reference to field getName can't be resolved. Reflection warning, complete/core.clj:44 - reference to field getName can't be resolved. Reflection warning, complete/core.clj:43 - reference to field getMethods can't be resolved. Reflection warning, complete/core.clj:43 - reference to field getDeclaredFields can't be resolved. Reflection warning, complete/core.clj:47 - call to endsWith can't be resolved. Reflection warning, complete/core.clj:48 - reference to field getName can't be resolved. Reflection warning, complete/core.clj:48 - call to endsWith can't be resolved. Reflection warning, complete/core.clj:49 - reference to field getPath can't be resolved. Reflection warning, complete/core.clj:48 - call to java.io.File ctor can't be resolved. Reflection warning, complete/core.clj:52 - call to endsWith can't be resolved. Reflection warning, complete/core.clj:54 - reference to field getName can't be resolved. Reflection warning, complete/core.clj:54 - reference to field getName can't be resolved. Reflection warning, complete/core.clj:53 - call to java.util.jar.JarFile ctor can't be resolved. Reflection warning, complete/core.clj:59 - reference to field getPath can't be resolved. Reflection warning, complete/core.clj:59 - call to replace can't be resolved. Reflection warning, complete/core.clj:59 - reference to field getPath can't be resolved. Reflection warning, complete/core.clj:59 - call to replace can't be resolved. Reflection warning, complete/core.clj:58 - call to java.io.File ctor can't be resolved. Reflection warning, complete/core.clj:64 - call to endsWith can't be resolved. Reflection warning, complete/core.clj:64 - call to contains can't be resolved. Reflection warning, complete/core.clj:64 - call to endsWith can't be resolved. Reflection warning, complete/core.clj:64 - call to contains can't be resolved. Reflection warning, complete/core.clj:68 - call to replace can't be resolved. Reflection warning, complete/core.clj:68 - call to replace can't be resolved. Reflection warning, complete/core.clj:92 - call to contains can't be resolved. Reflection warning, complete/core.clj:93 - call to contains can't be resolved. Reflection warning, complete/core.clj:98 - call to split can't be resolved. Reflection warning, complete/core.clj:108 - call to contains can't be resolved. Reflection warning, complete/core.clj:124 - call to startsWith can't be resolved. Reflection warning, complete/core.clj:124 - call to startsWith can't be resolved. Reflection warning, NO_SOURCE_PATH:1 - reference to field getLocalPort can't be resolved. nREPL server started on port 50335 ERROR: Unhandled REPL handler exception processing message {:id c2764dff-eb10-4e81-9f38-7160b80c3198, :op ack, :port 50335} java.net.SocketException: Socket closed at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:116) at java.net.SocketOutputStream.write(SocketOutputStream.java:153) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at clojure.tools.nrepl.transport$bencode$fn__1653.invoke(transport.clj:103) at clojure.tools.nrepl.transport.FnTransport.send(transport.clj:28) at clojure.tools.nrepl.ack$handle_ack$fn1780.invoke(ack.clj:42) at clojure.tools.nrepl.server$handleSTAR.invoke(server.clj:18) at clojure.tools.nrepl.server$handle$fn2086.invoke(server.clj:27) at clojure.core$binding_conveyor_fn$fn__4107.invoke(core.clj:1836) at clojure.lang.AFn.call(AFn.java:18) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) REPL-y 0.1.10 Clojure 1.4.0 Reflection warning, NO_SOURCE_PATH:1 - reference to field name can't be resolved. Exit: Control+D or (exit) or (quit) Commands: (user/help) Docs: (doc function-name-here) (find-doc "part-of-name-here") Source: (source function-name-here) (user/sourcery function-name-here) Javadoc: (javadoc java-object-or-class-here) Examples from clojuredocs.org: [clojuredocs or cdoc](user/clojuredocs name-here) (user/clojuredocs "ns-here" "name-here") user=> (require 'clojure.java.io) nil user=> (seq (.list (clojure.java.io/file "/home/j0nguk/android-sdk-linux/build-tools)))

_=>

alexander-yakushev commented 11 years ago

I should've told you to run the REPL from another project - Clojure-android projects are not quite fit to run an ordinary REPL from there.

I was interested if you can see that "17.0.0" directory from Clojure and apparently you cannot. I wonder why. Could you please double-check the file-system permissions on your Android SDK-folder, "build-tools" folder and "17.0.0" folder?

jukworks commented 11 years ago

Oh my god. I misconfigured {:android {:sdk-paht ...}} in .lein/profiles.clj. I put it to a different level...

{:user {:plugins [[lein-droid "0.1.0-preview5"]]} :android {:sdk-path "/home/j0nguk/android-sdk-linux/"}}

is my misconfiguration.

Of course,

{:user {:plugins [[lein-droid "0.1.0-preview5"]] :android {:sdk-path "/home/j0nguk/android-sdk-linux/"}}}

is right one.

I'm sorry for bothering you, and I appreciate for your kind response.

alexander-yakushev commented 11 years ago

I'm the one that should be sorry. Before preview5 lein-droid notified that SDK-path is not configured, but in this version it is used before the safety checks. Haven't noticed it.

I'm glad it works now! Feel free to contact me anytime.