12

I'm developing a standard Android app (in java), but would like to implement some of the non-UI "business logic" in clojure. Are there any downsides to doing this, or issues that I should be aware of that would make this a bad idea?

I've done a simple test - calling functions in a trivial clojure library from an Android app, and this appeared to work without any obvious issues.

I've seen comments about issues with regards to time to load clojure.jar, but in my case clojure is not handling the UI.

I'm not clear if there are any other memory or performance issues I should be concerned about.

Update 16th Jan 2017

I encountered some issues when trying to use some slightly more complex clojure libraries, specifically one that depends on core.async.

With standard clojure 1.8 as a dependency I tried to:

new ClassDefinedInClojure()

where ClassDefinedInClojure is the AOT generated java class, but I got:

java.lang.VerifyError: Rejecting class clojure.core.memoize.RetryingDelay because it failed compile-time verification

I assumed that this was the result of the same issue identified here:

http://dev.clojure.org/jira/browse/CLJ-1472

But the problem still existed even after I'd rebuilt clojure 1.8 with the patch (http://dev.clojure.org/jira/secure/attachment/15351/clj-1472-2.patch) applied.

I am aware of of the android specific build of clojure https://github.com/clojure-android/clojure, but to be honest not clear how this differs from normal clojure and why it is needed. I did try using this as an alternative to the standard clojure library, but had the same issue.

With respect to my original question, this was useful - http://blog.ndk.io/state-of-coa.html

Mark Melling
  • 1,562
  • 14
  • 15
  • 1
    Is it written for ART bytecode? Remember that Android does not use the JVM. – Gabe Sechan Jan 12 '17 at 22:47
  • 1
    @gabe-sechan I'm compiling the clojure library with AOT (:aot :all) if that's what you mean. – Mark Melling Jan 16 '17 at 15:47
  • 1
    @MarkMelling I just ran across this, and I'm trying to do what you set out to do. I'm stuck. I can't call even core Clojure functions from inside Android. Where did you find resources on this? – Ashton Wiersdorf Nov 15 '18 at 06:03
  • 1
    You might want to review the following StackOverflow questions and their answers: [SO - Clojure on Android](https://stackoverflow.com/questions/4651757/clojure-on-android), [SO - Android Adverse to Dynamic Languages](https://stackoverflow.com/questions/973386/android-adverse-to-dynamic-languages), [SO - Android App Development With Clojure](https://stackoverflow.com/questions/33593383/android-app-development-with-clojure) and this external page: [Lein-Droid Tutorial](https://github.com/clojure-android/lein-droid/wiki/Tutorial) – Bob Jarvis - Слава Україні Feb 16 '22 at 17:58

0 Answers0