Closed wiseman closed 10 years ago
Hello,
I ama little confused which libraries you are referring to. Lein-droid perfectly handles clojure libraries via :dependencies mechanism. You only need source level dependencies when you want to use Android library which contains android resources (limitation of current android build system). So can you please specify is it the former or the latter that you meant?
Oh, maybe I am confused. I had a compilation problem when I specified a dependency, then saw the docs about source dependencies and thought I could only use source deps. I'll try again and see if I can figure out what my issue is. Thanks for the response.
It could be that the library you want to use requires smth JVM-specific. Can you tell the name? I'll take a look whgen I get from the trip.
[ar-drone "0.1.8a"], which is my fork of https://github.com/gigasquid/clj-drone that i'm trying to make more suitable for use as a library, on android.
This is the error I get:
Compiling leiningen.hooks.clj-stacktrace-test
Exception in thread "main" java.io.FileNotFoundException: Could not locate leiningen/compile__init.class or leiningen/compile.clj on classpath: , compiling:(clj_stacktrace_test.clj:1:1)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3463)
at clojure.lang.Compiler.compile1(Compiler.java:7153)
at clojure.lang.Compiler.compile1(Compiler.java:7143)
at clojure.lang.Compiler.compile(Compiler.java:7219)
at clojure.lang.RT.compile(RT.java:423)
at clojure.lang.RT.load(RT.java:463)
at clojure.lang.RT.load(RT.java:436)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$compile$fn__5023.invoke(core.clj:5541)
at clojure.core$compile.invoke(core.clj:5540)
at user$eval7.invoke(form-init391813374377603751.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6609)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.Compiler.loadFile(Compiler.java:7020)
at clojure.main$load_script.invoke(main.clj:299)
at clojure.main$init_opt.invoke(main.clj:304)
at clojure.main$initialize.invoke(main.clj:332)
at clojure.main$null_opt.invoke(main.clj:367)
at clojure.main$main.doInvoke(main.clj:445)
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.main.main(main.java:37)
Caused by: java.io.FileNotFoundException: Could not locate leiningen/compile__init.class or leiningen/compile.clj on classpath:
at clojure.lang.RT.load(RT.java:468)
at clojure.lang.RT.load(RT.java:436)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:621)
at clojure.core$use.doInvoke(core.clj:5507)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at leiningen.hooks.clj_stacktrace_test$loading__4910__auto__.invoke(clj_stacktrace_test.clj:1)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3458)
... 27 more
Compilation failed.
My project.clj looks like this:
(defproject androne/androne "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"
:global-vars {*warn-on-reflection* true}
:source-paths ["src/clojure" "src"]
:java-source-paths ["src/java" "gen"]
:javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
:dependencies [[ar-drone "0.1.8a"]
[org.clojure-android/clojure "1.5.1-jb" :use-resources true]
[neko/neko "3.0.0-preview3"]]
:profiles {:dev {:dependencies [[android/tools.nrepl "0.2.0-bigstack"]
[compliment "0.0.2"]]
: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. Do it either here or in
;; ~/.lein/profiles.clj
;; :keystore-path "/home/user/.android/private.keystore"
;; :key-alias "mykeyalias"
:ignore-log-priority [:debug :verbose]
: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. Set the value according to your
;; available RAM.
;; :dex-opts ["-JXmx4096M"]
;; If previous option didn't work, uncomment this as well.
;; :force-dex-optimize true
:target-version "19"
:aot-exclude-ns ["clojure.parallel" "clojure.core.reducers"]})
If I take out the ar-drone dependency, compilation succeeds.
Apparently the problem was clj-stacktrace, which was being pulled in by the timbre logging library. I switched to clojure.tools.logging and compilation succeeded.
clj-stacktrace has this strange hook in the codebase, that uses leininingen.compile
namespace, without project requiring Leiningen anywhere. This is kind of strange, but it is not really Android-specific. I should ask technomancy about it someday.
Anyway, I'm glad the issue got resolved. Thank you!
On the side note, you could probably add leiningen.hooks.clj-stacktrace-test
namespace to :android
->:aot-exclude-ns
vector in project.clj, that should theoretically make it possible to compile clj-stacktrace.
I love lein droid. Great work, you've made a very fun tool!
Do you have a plan or any ideas for future enhancements of handling dependencies? I'm trying to figure out the best way to create a library that can be used in a standard clojure environment or on android--Using source dependencies seems to get pretty tedious once you start looking at dependencies of dependencies.
Would it be possible to auto-convert all jars in a dependency graph to Dalvik?