How to add external library with native binaries like pocketsphinx or yandex speechkit?

220 views
Skip to first unread message

Leonid K

unread,
Oct 1, 2015, 2:50:19 PM10/1/15
to clojure-android
Hello, everyone

Can you please help on how to add external library with native binaries like pocketsphinx or yandex speechkit to clojure-droid project?

This repo https://github.com/cmusphinx/pocketsphinx-android has both .jar file and .so native libraries.

I'm not sure if I should copy it to local project, or package it first, and how to configure project.clj.

(btw thank you clojure-droid team for very fast developer experience with lein-droid. I was able to hack something up just in several hours of coding using REPL :)

Leo

Alexander Yakushev

unread,
Oct 1, 2015, 2:51:58 PM10/1/15
to clojure-android
Message has been deleted

Leonid K

unread,
Oct 1, 2015, 4:03:30 PM10/1/15
to clojure-android
Hello, Alexander,

thank you for your reply!!!

I'm then trying to put .so to that path, and .jar to :external-classes-path, if I understood it correctly.

(I'm new to Java world. I managed currently to import external speech proejct into android studio, somehow build it, and find inside the directory structure app-debug.aar.
I guess there is a notion of 'local repositories', so now copying it into local repository or installing via maven tool is an option as well, I guess. First way seems faster)

Alexander Yakushev

unread,
Oct 1, 2015, 4:07:49 PM10/1/15
to clojure-android
Yes, you can either just list the files in :external-classes-paths and :native-libraries-paths respectively (easier, but less "proper"), or install AAR into your local maven repo and add as a regular dependency.

By the way, if a JAR includes .so files in correct subdirectories, and you put the jar to :external-classes-paths, then you don't have to unpack those natives and list them in :native-libraries-paths - lein-droid will do that automatically.

Leonid K

unread,
Oct 1, 2015, 4:10:22 PM10/1/15
to clojure...@googlegroups.com
Sorry for offtopic, but I just wanted to say thank you to all your work in speeding up clojure startup time, and also making android development so smooth for newcomers with lein droid and neko.

--
You received this message because you are subscribed to a topic in the Google Groups "clojure-android" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure-android/ccTZg_gLm5U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure-andro...@googlegroups.com.
To post to this group, send email to clojure...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojure-android.
For more options, visit https://groups.google.com/d/optout.

Alexander Yakushev

unread,
Oct 1, 2015, 4:17:05 PM10/1/15
to clojure-android
Thanks for your kind words, Leonid! I really appreciate them, and I'm very happy someone finds my work useful.
To unsubscribe from this group and all its topics, send an email to clojure-android+unsubscribe@googlegroups.com.
To post to this group, send email to clojure-android@googlegroups.com.

Leonid K

unread,
Oct 2, 2015, 3:39:48 AM10/2/15
to clojure-android
Well, I tried to create a /lib folder in the root of the project, and put .jar file an .aar file there, and then to juggle those two config parameters like this:

  :native-libraries-paths ["jni" "lib/speechkit.aar"]
  :external-classes-paths ["/home/valt/workspace/mirrored/lib"
                           "/home/valt/workspace/mirrored/lib/YandexSpeechKit.jar"]


My code imports files like this:
(:import (ru.yandex.speechkit Error ...))

Unfortunately, I'm still getting ClassNotFound exception during compilation, so I guess I am doing something wrong

Leonid K

unread,
Oct 2, 2015, 3:47:40 AM10/2/15
to clojure-android
I guess it might not be in a class path. I will try to fiddle config some more

 DEBUG=1 lein droid doall
Leiningen's classpath: /home/valt/.lein/self-installs/leiningen-2.5.2-standalone.jar
(Warning: profile :android-common not found.)
(Warning: profile :android-user not found.)
Applying task droid to [doall]
Generating manifest...
Merging secondary manifests: (#object[java.io.File 0x1e411d81 /home/valt/workspace/mirrored/target/debug/aar-extracted/com.android.support_multidex_aar_1.0.0/AndroidManifest.xml])
Generating R.java files...
/home/valt/Android/Sdk/build-tools/23.0.1/aapt package -f -m -M /home/valt/workspace/mirrored/target/debug/AndroidManifest.xml -S /home/valt/workspace/mirrored/target/debug/res -S /home/valt/workspace/mirrored/res -S /home/valt/workspace/mirrored/target/debug/aar-extracted/com.android.support_multidex_aar_1.0.0/res -I /home/valt/Android/Sdk/platforms/android-19/android.jar -J /home/valt/workspace/mirrored/target/debug/gen --output-text-symbols /home/valt/workspace/mirrored/target/debug/gen --auto-add-overlay --generate-dependencies

Running javac with [-target 1.6 -source 1.6 -Xlint:-options @/tmp/.leiningen-cmdline335941856045983072.tmp]
(Warning: profile :android-common not found.)
(Warning: profile :android-user not found.)
Compiling 2 source files to /home/valt/workspace/mirrored/target/debug/classes
Applying task javac to nil
Running javac with [-target 1.6 -source 1.6 -Xlint:-options @/tmp/.leiningen-cmdline6379574034023238170.tmp]
Compiling Clojure files...
Project classpath: (/home/valt/Android/Sdk/tools/support/annotations.jar /home/valt/Android/Sdk/platforms/android-19/android.jar /home/valt/workspace/mirrored/test /home/valt/workspace/mirrored/src/clojure /home/valt/workspace/mirrored/src /home/valt/workspace/mirrored/resources /home/valt/workspace/mirrored/target/debug/classes /home/valt/.m2/repository/org/clojure-android/clojure/1.7.0-r2/clojure-1.7.0-r2.jar /home/valt/.m2/repository/neko/neko/4.0.0-alpha5/neko-4.0.0-alpha5.jar /home/valt/.m2/repository/org/clojure/tools.nrepl/0.2.10/tools.nrepl-0.2.10.jar /home/valt/workspace/mirrored/target/debug/aar-extracted/com.android.support_multidex_aar_1.0.0/classes.jar)
Build type: debug, dynamic compilation: enabled, remote REPL: enabled.
Applying task javac to nil

Leonid K

unread,
Oct 2, 2015, 2:41:17 PM10/2/15
to clojure-android
RESOLVED

by moving the key :external-classes-paths under :android key of profiles.clj

yay.

Alexander Yakushev

unread,
Oct 3, 2015, 10:23:25 AM10/3/15
to clojure-android
Good to hear that!
Reply all
Reply to author
Forward
0 new messages