Clojure core.async?

489 views
Skip to first unread message

Frozenlock

unread,
May 30, 2014, 5:06:19 PM5/30/14
to clojure...@googlegroups.com
Has anybody used it?

When I try to include a library that's using it, I get 
"Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/analyzer__init.class or cljs/analyzer.clj on classpath: , compiling:(ioc_macros.clj:12:1)"

Is there some magic voodoo that one needs to do to be able to use it?

Adam Clements

unread,
May 31, 2014, 6:19:32 AM5/31/14
to clojure...@googlegroups.com
I've been using core async with android no problems. It strikes me that you're trying to import the clojurescript version there though... make sure you're importing clojure.core.async and not cljs.core.async everywhere


Adam


--
You received this message because you are subscribed to the Google Groups "clojure-android" group.
To unsubscribe from this group and stop receiving emails from it, 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,
May 31, 2014, 12:44:17 PM5/31/14
to clojure...@googlegroups.com
Just saying, if some library by chance depends on Clojurescript's core.async, you can exclude the dependency from the build using some Leiningen magic. I don't remember the syntax, but you can probably look it up in Leiningen docs.


On Saturday, May 31, 2014 12:19:32 PM UTC+2, Adam Clements wrote:
I've been using core async with android no problems. It strikes me that you're trying to import the clojurescript version there though... make sure you're importing clojure.core.async and not cljs.core.async everywhere


Adam


On Fri, May 30, 2014 at 10:06 PM, Frozenlock <froze...@gmail.com> wrote:
Has anybody used it?

When I try to include a library that's using it, I get 
"Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/analyzer__init.class or cljs/analyzer.clj on classpath: , compiling:(ioc_macros.clj:12:1)"

Is there some magic voodoo that one needs to do to be able to use it?

--
You received this message because you are subscribed to the Google Groups "clojure-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-android+unsubscribe@googlegroups.com.
To post to this group, send email to clojure-android@googlegroups.com.

Frozenlock

unread,
Jun 1, 2014, 3:23:42 AM6/1/14
to clojure...@googlegroups.com
That's odd... it's really a Clojure application. Ran and tested on the JVM.
I'll post more info if I find some.

Adam Clements

unread,
Jun 1, 2014, 4:28:05 AM6/1/14
to clojure...@googlegroups.com

One possibility - do you have :aot :all in your project file? On which case it will try to compile every namespace, whether you :require it or not, which in this case might be a file which uses cljs but never gets loaded in the jam version. In my application I specify :aot as a vector of namespaces to include. You don't need to specify every namespace, it will walk through the requires of the ones you do specify, but be careful to include things like the nrepl namespace which only gets required at runtime and include any library namespace you might want to require in the repl at runtime.

Adam

Alexander Yakushev

unread,
Jun 1, 2014, 4:42:30 AM6/1/14
to clojure...@googlegroups.com
Or you could also add superfluous namespaces to :aot-exclude-ns vector in project.clj

Ben Zaporzan

unread,
Jun 17, 2014, 9:58:49 AM6/17/14
to clojure...@googlegroups.com
I've been running into the same issues, and i'm not really sure how to fix it. Did you have any luck fixing this problem?

Ben Zaporzan

unread,
Jun 17, 2014, 10:17:40 AM6/17/14
to clojure...@googlegroups.com
Please excuse my last post, I looked into what Alexander Yakushev said, and used :aot-exclude-ns

                        :aot-exclude-ns [cljs.core.async.macros
                                         cljs.core.impl-ioc-macros]

On Friday, May 30, 2014 5:06:19 PM UTC-4, Frozenlock wrote:

Alexander Yakushev

unread,
Jun 17, 2014, 11:43:17 AM6/17/14
to clojure...@googlegroups.com
Did it work for you, Ben?

Ben Zaporzan

unread,
Jun 17, 2014, 12:07:49 PM6/17/14
to clojure...@googlegroups.com
Yep, it turned out it was due to the nature of :aot :all-with-unused

I got to keep :all-with-unused by using :aot-exclude-ns

this is what my project file looks like currently


maybe someone would find this useful


--
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/2MleX4O9T7c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure-andro...@googlegroups.com.

Alexander Yakushev

unread,
Jun 17, 2014, 2:42:21 PM6/17/14
to clojure...@googlegroups.com
Thank you for the answer!


On Tuesday, June 17, 2014 7:07:49 PM UTC+3, Ben Zaporzan wrote:
Yep, it turned out it was due to the nature of :aot :all-with-unused

I got to keep :all-with-unused by using :aot-exclude-ns

this is what my project file looks like currently


maybe someone would find this useful
On Tue, Jun 17, 2014 at 11:43 AM, Alexander Yakushev <al...@bytopia.org> wrote:
Did it work for you, Ben?


On Tuesday, June 17, 2014 5:17:40 PM UTC+3, Ben Zaporzan wrote:
Please excuse my last post, I looked into what Alexander Yakushev said, and used :aot-exclude-ns

                        :aot-exclude-ns [cljs.core.async.macros
                                         cljs.core.impl-ioc-macros]

On Friday, May 30, 2014 5:06:19 PM UTC-4, Frozenlock wrote:
Has anybody used it?

When I try to include a library that's using it, I get 
"Exception in thread "main" java.io.FileNotFoundException: Could not locate cljs/analyzer__init.class or cljs/analyzer.clj on classpath: , compiling:(ioc_macros.clj:12:1)"

Is there some magic voodoo that one needs to do to be able to use it?

--
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/2MleX4O9T7c/unsubscribe.
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.

Wei "pw" Peng

unread,
Jun 25, 2014, 10:30:09 PM6/25/14
to clojure...@googlegroups.com
Thanks for sharing the solution, Ben and Alex.

I ran into the same issue, and

:aot-exclude-ns [cljs.core.async.macros
                         cljs.core.impl-ioc-macros]

these 2 exclusions (they are the ones that trigger the compilation errors), and now compile with no problem.

Have not tested core.async yet, not completely sure if excluding these dependencies would have other consequences.

Nathan

unread,
Jul 25, 2014, 6:52:25 PM7/25/14
to clojure...@googlegroups.com
The :aot-exclude-ns [cljs.core.async.macros cljs.core.impl-ioc-macros] trick works for compilation for me, but as soon as I :require clojure.core.async my whole application crashes.

I've attached the project.clj, the main.clj and the log file of the crash to this message. Maybe you guys can figure out what's wrong.
It should be noted that async works over nrepl, if the application is already running, which it does if you remove the :require of clojure.core.async in the source file, compile it and run it on your android.
project.clj
log.txt
main.clj

Daniel Solano Gómez

unread,
Jul 25, 2014, 8:18:35 PM7/25/14
to clojure...@googlegroups.com
Hello, Nathan,

Last time I tried out core.async, I ended up loading one of the namespaces it depends on first, otherwise loading all of the namespaces required by core.async resulted in a stack overflow. Could go see if that fixes your problem?

Sincerely,
Daniel
y

Nathan

unread,
Jul 25, 2014, 8:34:50 PM7/25/14
to clojure...@googlegroups.com
I'd love to try out. Could you be a bit more specific though? I'm not quite sure what to change about my code.

nr,
Nathan

Daniel Solano Gómez

unread,
Jul 25, 2014, 9:49:46 PM7/25/14
to clojure...@googlegroups.com
On Fri Jul 25 17:34 2014, Nathan wrote:
> I'd love to try out. Could you be a bit more specific though? I'm not quite
> sure what to change about my code.


Sure. clojure.core.async relies on many other namespaces. Starting
from a relatively fresh environment, loading all of these can blow the
stack on Android.


As a workaround, require one or more of these namespace dependencies
before requiring clojure.core.async.

For example, you could try something like:

(require 'clojure.test)
(require 'clojure.core.cache)
(require 'clojure.core.async)


I am not sure if something like the following will work:

(require 'clojure.test 'clojure.core.cache 'clojure.core.async)

You should be able to replicate either of the above using the ns macro.

Sincerely,

Daniel
> You received this message because you are subscribed to the Google Groups "clojure-android" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clojure-andro...@googlegroups.com.

Nathan

unread,
Jul 25, 2014, 11:00:09 PM7/25/14
to clojure...@googlegroups.com
Awesome, that worked.

I ended up putting the dependencies into the ns macro.
Thanks a lot.

Sincerely,
Nathan

Adam Clements

unread,
Jul 26, 2014, 1:34:40 AM7/26/14
to clojure...@googlegroups.com

A far more reliable solution to this problem is to not aot all by default as a number of libraries include nanespaces that are only intended to be used in certain circumstances and maintaining a long list of exclusions is far more tiresome than just including the occasional extra namespace which doesn't get picked up automatically by scanning requires

You received this message because you are subscribed to the Google Groups "clojure-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-andro...@googlegroups.com.

Adam Clements

unread,
Jul 26, 2014, 1:41:59 AM7/26/14
to clojure...@googlegroups.com

Oh and I load clojure in an async task which has a larger than normal stack size (the default is actually pretty tiny) so I can load core async without any hacking around. I've been using it for months without a hitch

Max Gonzih

unread,
Jul 9, 2015, 1:51:56 PM7/9/15
to clojure...@googlegroups.com
I was trying to add core.async to the lein-droid project today and at first got stuck with the similar problem.

Adding following to the dev profile solved this problem.

:aot-exclude-ns [cljs.core.async.macros cljs.core.async.impl.ioc-macros]

I was unable to run my application because during DEX generation I got following error:

trouble writing output: Too many field references: 70189; max is 65536.

Is there a way to solve this problem or should I just try to cut down amount of dependencies?
Like removing cider from deps for example.

Thanks!

Alexander Yakushev

unread,
Jul 9, 2015, 1:56:13 PM7/9/15
to clojure...@googlegroups.com, gon...@gmail.com
Hello Max,

There is a way to circumvent dex method limit by using a special multidex dupport library and some extra magic. This functionality is planned for lein-droid 0.4.0 but it's not there just yet. I will try to fix this problem when I get back from the vacation in one week.

Best regards,
Alex

Message has been deleted

Max Gonzih

unread,
Jul 9, 2015, 2:57:14 PM7/9/15
to clojure...@googlegroups.com, gon...@gmail.com
Ok, thanks for your reply.

Sorry for double post.
I was not sure if my post went for verification or my browser just did nothing.

Adam Clements

unread,
Jul 10, 2015, 4:16:18 AM7/10/15
to clojure...@googlegroups.com, gon...@gmail.com

I have a working multi-dex setup, but it's really hacky and not suitable for adding to lein droid. I could write it up in its current state if you would like a temporary fix


--

Max Gonzih

unread,
Jul 10, 2015, 4:58:32 AM7/10/15
to Adam Clements, clojure...@googlegroups.com
I can wait of course, i'm still just toying with clojure-android.
But can you describe your solution in a couple of words.
Maybe it's silly question, but I'm not familiar with android infrastructure, so what you are talking about sounds like a mystery to me.

Adam Clements

unread,
Jul 10, 2015, 6:03:13 AM7/10/15
to Max Gonzih, clojure...@googlegroups.com

The android build process compiles java byte code to dex code. The dex file format is limited to 65k method references, but there is an option to tell the dexing tool that it should instead generate multiple .Dex files, and if you use the android support library MultiDexApplication class for your application, it will load the multiple dex files instead of just the one it expects. However, this loading happens after your program starts, so you need to make sure that all the classes your program needs at the very start are in your primary dex. There is a script for this which basically runs a proguard script to list all the classes directly linked from your activities and services. I found I needed to add clojure core to this produced file so it would keep it in the main dex, but there is no easy way I found to configure this without tweaking the proguard file in the android sdk itself, and that's the hacky bit - I copied the script from within the android sdk and tweaked it to my needs

Alexander Yakushev

unread,
Jul 26, 2015, 5:15:31 AM7/26/15
to clojure-android, froze...@gmail.com, froze...@gmail.com
Hello Max,

Newest lein-droid 0.4.0-alpha5 has the support for multi-dex projects. Details: https://github.com/clojure-android/lein-droid/wiki/MultiDEX-project . You also need Neko 4.0.0-alpha2 for this to work.

If you try it, please share your experience. Thanks!

Best regards,
Alex

Max Gonzih

unread,
Jul 27, 2015, 8:23:25 AM7/27/15
to clojure...@googlegroups.com
Hi,

Great to see this update! I just tried to bump dependencies and looks like I have new error:

Creating multi DEX....
--incremental is not supported with --multi-dex

Should I install anything android-sdk related to fix that?

Thanks!
--
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/2MleX4O9T7c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure-andro...@googlegroups.com.

Alexander Yakushev

unread,
Jul 27, 2015, 8:25:54 AM7/27/15
to clojure...@googlegroups.com
No, you just have to remove "--incremental" from :dex-opts. It says so in the docs;).

--
You received this message because you are subscribed to the Google Groups "clojure-android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-andro...@googlegroups.com.

Max Gonzih

unread,
Jul 27, 2015, 8:32:12 AM7/27/15
to clojure...@googlegroups.com
Oh, yes. That works. Now apk crashes on when I'm trying to run it :)
Thanks a lot, I will investigate what is going on inside my apk!

Cheers!

Alexander Yakushev

unread,
Jul 27, 2015, 8:34:32 AM7/27/15
to clojure...@googlegroups.com
No problem, `adb logcat` should tell you what's wrong. It is possible that some extra classes have to be included into primary DEX. Post here the stacktrace if you think it is related to the DEX process.

Max Gonzih

unread,
Jul 27, 2015, 9:15:12 AM7/27/15
to clojure...@googlegroups.com
Looks like it's related to the dex generation after all:

I/ActivityManager( 1155): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=gnzh.android.hello.world.debug/gnzh.android.hello.world.SplashActivity bnds=[571,96][763,288]} from pid 1538
I/ActivityManager( 1155): Start proc gnzh.android.hello.world.debug for activity gnzh.android.hello.world.debug/gnzh.android.hello.world.SplashActivity: pid=21038 uid=10190 gids={50190, 3003}
D/WhetstoneService( 1507): set foreground process size 1 pid:21038pacakgeName:gnzh.android.hello.world.debug
I/KLO_Stability( 1782): [am_crash][1438002776]:[21038,0,gnzh.android.hello.world.debug,8961606,java.lang.ClassNotFoundException,Didn't find class "clojure.lang.DalvikDynamicClassLoader" on path: DexPathList[[zip file "/data/app/gnzh.android.hello.world.debug-2.apk"],nativeLibraryDirectories=[/data/app-lib/gnzh.android.hello.world.debug-2, /vendor/lib, /system/lib]],BaseDexClassLoader.java,56]
E/AndroidRuntime(21038): Process: gnzh.android.hello.world.debug, PID: 21038
E/AndroidRuntime(21038): Caused by: java.lang.ClassNotFoundException: Didn't find class "clojure.lang.DalvikDynamicClassLoader" on path: DexPathList[[zip file "/data/app/gnzh.android.hello.world.debug-2.apk"],nativeLibraryDirectories=[/data/app-lib/gnzh.android.hello.world.debug-2, /vendor/lib, /system/lib]]
W/KloServer( 1507): Aborted broadcast does not supprt for: gnzh.android.hello.world.debug
W/ActivityManager( 1155):   Force finishing activity gnzh.android.hello.world.debug/gnzh.android.hello.world.SplashActivity
I/Timeline( 1155): Timeline: Activity_windows_visible id: ActivityRecord{41dede48 u0 gnzh.android.hello.world.debug/gnzh.android.hello.world.SplashActivity t104 f} time:67451256
W/WhetstoneService( 1507): do not trim { PackageName :gnzh.android.hello.world.debug Pid: 21038 Uid: 0 Start by: activity Score:50 Old score:50 state:0 mBackgroundTimeInMillis:1438002776375 WakelockCount:0 wakelogsize:0  ActivityDestroied:false Activity size: 0 PackageInfo:{WhetstonePackageInfo#PacakgeName:gnzh.android.hello.world.debugFlag:1073747136 [,TRIMHEAPS,SOFT_RESET,ZRAM,FLAG_DEAL_SCHEDULE] Type:0[] } tasknum:104}
I/ActivityManager( 1155): Process gnzh.android.hello.world.debug (pid 21038) has died.

Alexander Yakushev

unread,
Jul 27, 2015, 9:25:28 AM7/27/15
to clojure-android, gon...@gmail.com, gon...@gmail.com
So the multi-dexer didn't figure out it should keep DalvikDynamicClassLoader in the primary DEX. But it's OK, you can tell it to do so. Open your "build/proguard-multi-dex.cfg" file (or wherever you've put it) and add the following line at the bottom:

-keep public class clojure.lang.**;

This will make multi-dexer include all those Clojure's classes into the main dex so that they will be available during application initialization.

Hope this helps, please keep me updated on your progress.
Reply all
Reply to author
Forward
0 new messages