clojure-android / neko Goto Github PK
View Code? Open in Web Editor NEWThis project forked from sattvik/neko
The Clojure/Android Toolkit
License: Other
This project forked from sattvik/neko
The Clojure/Android Toolkit
License: Other
The version currently deployed in Clojars do not include the last changes (:implements).
neko.ui/traits.clj references static fields of android.widget.RelativeLayout, such as (among others) ALIGN_PARENT_END, which have only been introduced in API 17.
This breaks neko for all target APIs < 17.
I wrote tests years ago, but now they are all disabled. We need to develop a strategy to get them working again.
Looks like marginalia docs are missing, the link to http://alexander-yakushev.github.io/neko/ gives me 404. Tried to generate them myself but that failed with missing android.* packages.
Hi,
First of all, thanks a lot for your work! I'm currently playing with the combo lein-droid/neko and I think that it could be awesome to have some more examples (like how to interact with a web-view in a layout. I looked at the documentation and there https://github.com/sattvik/Clojure-Android-Examples/blob/master/basic/src/clojure/com/sattvik/android/clojure/basic/ClojureBrowser.clj, but the latter seems to be outdated).
I have been trying to follow some tutorials on android clojure development, mainly this one:
https://github.com/alexander-yakushev/events/blob/master/tutorial.md
However I can't get the *a macro to work correctly. At the moment I try to work directly from a "lein droid repl" in the console as I had some problems with cider before so I want to make sure that my problems with the *a macro is unrelated to that.
Am I doing something wrong here? What?
Should *a evaluate to nil?
When I evaluate the on-ui form I get the following error on the phone:
java.lang.AssertionError: Assert failed: (instance? Activity activity)
Any suggestions on what I should do to solve this problem?
This is what I do:
rm -Rf events3/
lein new droid events3 org.stuff.events :activity MainActivity :target-sdk 15 :app-name EventsListing
cd events3/
lein droid doall
At this point I get the default application on my connected phone (Galaxy Note 3 android 5.0) and everything looks good. I start the repl:
lein droid repl
REPL-y 0.3.7, nREPL 0.2.10
Clojure 1.7.0
Dalvik 0.9
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=> (+ 1 1)
2
user=> (in-ns 'org.stuff.events.main)
#object[clojure.lang.Namespace 0x384a57b0 "org.stuff.events.main"]
org.stuff.events.main=> (on-ui (neko.notify/toast "Hello"))
true
org.stuff.events.main=> (*a)
nil
org.stuff.events.main=> (*a :main)
nil
org.stuff.events.main=> (def main-layout [:linear-layout {:orientation :vertical}
#=> [:edit-text {:hint "Event name"}]
#=> [:edit-text {:hint "Event location"}]])
#'org.stuff.events.main/main-layout
org.stuff.events.main=> (defactivity org.stuff.events.MainActivity
#=> :key :main
#=>
#=> (onCreate [this bundle]
#=> (.superOnCreate this bundle)
#=> (on-ui
#=> (set-content-view! (*a) main-layout))
#_=> ))
#'org.stuff.events.main/MainActivity-onCreate
org.stuff.events.main=> (on-ui
#_=> (set-content-view! (*a) main-layout))
true
org.stuff.events.main=> (neko.debug/*a :main)
nil
org.stuff.events.main=> (neko.debug/*a)
nil
BTW: My .lein/profiles look like this:
{:user {:plugins [ [lein-droid "0.4.6"] ] }
:android-common {:dependencies [[org.clojure/tools.nrepl "0.2.12"]]
:android {:sdk-path "/home/matny/prg/Android/Sdk"}}
:android-user {;;:dependencies [ [cider/cider-nrepl "0.14.0"] ]
:android {:aot-exclude-ns ["cider.nrepl.middleware.util.java.parser"
"cider.nrepl" "cider-nrepl.plugin"]}
}
:repl {:dependencies [[org.clojure/tools.nrepl "0.2.12"]]}
}
Regards,
Mattias Nyrell
The text-size trait uses the setTextSize (float size)
method, which according to the API docs takes a size in scaled pixels, that is :sp
However the trait applies to-dimension
, which yields px, resulting in overall larger text than intended.
Proposed Fix: Use setTextSize (int unit, float size)
directly, skipping the manual conversion.
with the most recent neko Snapshot, menu generation fails with
Assert failed: (and (keyword? widget-kw) (map? attributes))
at menu generation. The unmodifed code runs fine with beta6
Hi Alex,
There are two misspellings in neko.init:
"::start-nrepl-sever" should be "::start-nrepl-server"
I detect this when hacking TBNL (https://github.com/pw4ever/tbnl) to make REPL work in release mode :)
Wei.
Issue by kenrestivo from Monday Dec 30, 2013 at 04:51 GMT
Originally opened as #4
I am having a terrible time trying to get neko to work in release mode. In development mode it works perfectly. In release mode, Big Trouble.
I'm first of all able to get it to fail spectacularly with the bare minimum template hello world app from
lein droid new release-crash-test test.crash
I'm using [lein-droid "0.2.0"] and javac 1.7.0_03.
Trying to build the example provide by lein-droid's new template, without any changes, and using "lein droid release", I get this assplosion:
Performing task 'do' with profile(s): 'droid'
Generating R.java...
Compiling 2 source files to /mnt/sdcard/tmp/release-crash-test/target/classes
Compiling Clojure files...
Build type: release, dynamic compilation: disabled, remote REPL: disabled.
Compiling test.crash.main
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(test/crash/main.clj:11:6)
at clojure.lang.Compiler.analyze(Compiler.java:6380)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3624)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6562)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3624)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6562)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3573)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6562)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5708)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5139)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3751)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6558)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6548)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:529)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6560)
at clojure.lang.Compiler.analyze(Compiler.java:6361)
at clojure.lang.Compiler.analyze(Compiler.java:6322)
at clojure.lang.Compiler.compile1(Compiler.java:7148)
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-init2888939025094326106.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.lang.RuntimeException: Unable to resolve symbol: a in this context
at clojure.lang.Util.runtimeException(Util.java:219)
at clojure.lang.Compiler.resolveIn(Compiler.java:6874)
at clojure.lang.Compiler.resolve(Compiler.java:6818)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6779)
at clojure.lang.Compiler.analyze(Compiler.java:6343)
... 70 more
Compilation failed.
Error encountered performing task 'do' with profile(s): 'droid'
Suppressed exit
Compilation exited abnormally with code 1 at Sun Dec 29 20:31:07
Bad.
OK I try a few other hacks. Let's try
Modified src/clojure/test/crash/main.clj
diff --git a/src/clojure/test/crash/main.clj b/src/clojure/test/crash/main.clj
index 93a2225..50d4085 100644
--- a/src/clojure/test/crash/main.clj
+++ b/src/clojure/test/crash/main.clj
@@ -4,10 +4,9 @@
[neko.ui :only [make-ui]]))
(defactivity test.crash.MainActivity
- :def a
:on-create
(fn [this bundle]
(on-ui
- (set-content-view! a
+ (set-content-view! test.crash.MainActivity
(make-ui [:linear-layout {}
[:text-view {:text "Hello from Clojure!"}]])))))
That compiles! But, alas, it gets worse.
E AndroidRuntime(4297) FATAL EXCEPTION: main
E AndroidRuntime(4297) java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{test.crash/test.crash.SplashActivity}: java.lang.ClassNotFoundException: test.crash.SplashActivity
E AndroidRuntime(4297) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1993)
E AndroidRuntime(4297) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
E AndroidRuntime(4297) at android.app.ActivityThread.access$600(ActivityThread.java:132)
E AndroidRuntime(4297) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
E AndroidRuntime(4297) at android.os.Handler.dispatchMessage(Handler.java:99)
E AndroidRuntime(4297) at android.os.Looper.loop(Looper.java:137)
E AndroidRuntime(4297) at android.app.ActivityThread.main(ActivityThread.java:4575)
E AndroidRuntime(4297) at java.lang.reflect.Method.invokeNative(Native Method)
E AndroidRuntime(4297) at java.lang.reflect.Method.invoke(Method.java:511)
E AndroidRuntime(4297) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
E AndroidRuntime(4297) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
E AndroidRuntime(4297) at dalvik.system.NativeStart.main(Native Method)
E AndroidRuntime(4297) Caused by: java.lang.ClassNotFoundException: test.crash.SplashActivity
E AndroidRuntime(4297) at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E AndroidRuntime(4297) at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E AndroidRuntime(4297) at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E AndroidRuntime(4297) at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
E AndroidRuntime(4297) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1984)
E AndroidRuntime(4297) ... 11 more
W ActivityManager(184) Force finishing activity test.crash/.SplashActivity
W InputManagerService(184) Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40e4bb80
W ActivityManager(184) Activity pause timeout for ActivityRecord{40d5a3f8 test.crash/.SplashActivity}
E (184) ../../accel.c|inv_get_accel_data|141 returning 146
E (184) ../../mlFIFO.c|inv_read_and_process_fifo|588 returning 146
E (184) ../../ml.c|inv_update_data|518 returning 146
E (184) inv_update_data error (code 146)
E (184) ../../accel.c|inv_get_accel_data|141 returning 245
E (184) ../../mlFIFO.c|inv_read_and_process_fifo|588 returning 245
E (184) ../../ml.c|inv_update_data|518 returning 245
E (184) inv_update_data error (code 245)
W ActivityManager(184) Activity destroy timeout for ActivityRecord{40d5a3f8 test.crash/.SplashActivity}
What the... why? What? That's weird.
OK OK, maybe my stubborn clinging to javac 1.7 is a problem. I update-alternatives and set javac and java to 1.6.0_45.
Ooh, a different crash! Now it's this:
W dalvikvm(4398) threadid=1: thread exiting with uncaught exception (group=0x40a5a1f8)
E AndroidRuntime(4398) FATAL EXCEPTION: main
E AndroidRuntime(4398) java.lang.AssertionError: Assert failed: (activity? activity)
E AndroidRuntime(4398) at neko.activity$set_content_view_BANG_.invoke(activity.clj:44)
E AndroidRuntime(4398) at test.crash.main$MainActivity_onCreate$fn__630$fn__631.invoke(main.clj:11)
E AndroidRuntime(4398) at neko.threading$on_ui_STAR_.invoke(threading.clj:54)
E AndroidRuntime(4398) at test.crash.main$MainActivity_onCreate$fn__630.invoke(main.clj:8)
E AndroidRuntime(4398) at test.crash.main$MainActivity_onCreate.invoke(main.clj:6)
E AndroidRuntime(4398) at test.crash.MainActivity.onCreate(Unknown Source)
E AndroidRuntime(4398) at android.app.Activity.performCreate(Activity.java:4465)
E AndroidRuntime(4398) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E AndroidRuntime(4398) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
E AndroidRuntime(4398) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
E AndroidRuntime(4398) at android.app.ActivityThread.access$600(ActivityThread.java:132)
E AndroidRuntime(4398) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
E AndroidRuntime(4398) at android.os.Handler.dispatchMessage(Handler.java:99)
E AndroidRuntime(4398) at android.os.Looper.loop(Looper.java:137)
E AndroidRuntime(4398) at android.app.ActivityThread.main(ActivityThread.java:4575)
E AndroidRuntime(4398) at java.lang.reflect.Method.invokeNative(Native Method)
E AndroidRuntime(4398) at java.lang.reflect.Method.invoke(Method.java:511)
E AndroidRuntime(4398) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
E AndroidRuntime(4398) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
E AndroidRuntime(4398) at dalvik.system.NativeStart.main(Native Method)
W ActivityManager(184) Force finishing activity test.crash/.MainActivity
W ActivityManager(184) Activity pause timeout for ActivityRecord{4119d6b0 test.crash/.MainActivity}
I Process(4398) Sending signal. PID: 4398 SIG: 9
I WindowManager(184) WIN DEATH: Window{4125f650 test.crash/test.crash.SplashActivity paused=false}
I ActivityManager(184) Process test.crash (pid 4398) has died.
W ActivityManager(184) Activity destroy timeout for ActivityRecord{40ea9920 test.crash/.SplashActivity}
W ActivityManager(184) Activity destroy timeout for ActivityRecord{4119d6b0 test.crash/.MainActivity}
And yes, I'm remebering to run "lein clean" before each of the above compilations, just to make sure.
So, at this point I have to give up on trying to make an app with lein-droid and neko. Sadly, I had a working app already finished and ready for testing, but only when built as debug. If release builds crash in bizarre and inexplicable ways then I guess there's no point in continuing the project. Oh well. It was fun for a while though. Could be very promising in the future.
how to get phone camera access using neko?
Hello and thank you for the great library.
I haven't been able to figure out the best way to interface directly with the android API, specifically I need to access the Bluetooth functionality. (http://developer.android.com/reference/android/bluetooth/package-summary.html)
Looking through your documentation I don't see any sensor interfacing (could be missing it). So I assume that Neko doesn't have built in Bluetooth interaction.
Is it possible to do this via direct interop? If so how would you suggest I start?
Thanks,
-Boris
It's possible that I've done something wonky, but I have image-buttons being defined in an adapter for a GridView, and for the most part working properly. However, calling a function defined elsewhere in the same file in the onClick procedure is causing "java.lang.RuntimeException: Unable to resolve symbol: in this context, compiling:(NO_SOURCE_PATH:0:0)" errors, even though the same exact call can be run, successfully, in the REPL.
In fact, what it's doing is looking up an entry in a predefined map, 'function-name, and eval-ing that to call function-name, which it isn't finding. Am I missing something here, or is the onClickListener having issues with either the scope or the quoting somehow?
I create a lein droid project by lein new droid project your.project
, then run lein droid doall
success create apk and install apk to my Android.
So i open the repl lein droid repl
, and test (on-ui (neko.notify/toast "Hello"))
, my Android will notify "Hello" ok .
But I use Emacs Cider connect the repl (localhost:9999) , then run C-c C-k
, it will Erro :
I don't know how to do, i try import VoiceInteractor class , but it's failed.
Thanks :-)
Besides the weight layout param, could you also add gravity for linear-layouts?
Came across this as I was going through Kris's tutorial. Here is the code in question:
(declare ^android.widget.LinearLayout mylayout)
(declare add-event)
(defn get-elmt [elmt]
(elmt (.getTag mylayout)))
(defn set-elmt [elmt s]
(on-ui (config (elmt (.getTag mylayout)) :text s)))
(defn add-event []
(set-elmt ::listing "TEST SETTING TEXT"))
(def main-layout [:linear-layout {:orientation :vertical,
:id-holder :true
:def `mylayout}
[:edit-text {:hint "Event name",
:id ::name}]
[:edit-text {:hint "Event location",
:text "Partay Town!"
:id ::location}]
[:button {:text "+ Event"
:on-click (fn [_] (add-event))}]
[:text-view {:text @listing
:id ::listing}]])
Calling add-event in the activity crashes the app, with the error:
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
The change introduced to keyword->static-field with commit fc4dae4 breaks neko.context/get-service because the function signature does not fit anymore.
Hi,
So I've been experimenting with references and watches, and I came with idea of a trait that allows you to hook to the reference and alter the widget when reference value changes:
(deftrait :ref-text [^android.widget.TextView wdg {:keys [ref-text]}]
(add-watch ref-text nil
(fn [_ _ o n] (post wdg (.setText wdg n)))))
This helped me to refrain from fetching widgets by ids/vars and just allowed to focus on the values prepared for them:
(def txt (atom nil))
(def ui [:linear-layout {:id-holder true}
[:text-view {:text "Hello from Clojure!!!"}]
[:edit-text {:text "Initial text" :ref-text txt}]])
(reset! txt "Some other text")
There is one issue here: I haven't hooked to the widget destroy event to release the reference that watcher holds (I haven't yet found the way to do it, am not very knowledgeable in android SDK ;) ), but I'm pretty sure it can easily be done.
Real question is, do you think it would be feasible to alter existing traits to work this way if the value specified is a reference (just additional case)? Many traits would benefit from such thing, and it would give neko that 'reactive' feel (possibility of using dataflow programming a'la javelin for example, is so tempting). Or whether it's better as an 'add-on' (like I did in my code)?
Issue by osbert from Tuesday Jul 09, 2013 at 22:38 GMT
Originally opened as #3
I'd like to deploy my own releases/snapshots to clojars to be able to make my own changes to neko and/or experiment with neko.ui.menu given that 3.0.0-SNAPSHOT is currently a bit old, but can't seem to find any documentation on how to build a neko jar suitable for deployment to clojars. I've tried:
lein jar - Fails because it cannot find symbols like android.view.View, android.widget.BaseAdapter when trying to compile InterchangeableListAdapter.java.
ant -Dsdk.dir=$ANDROID_HOME release - This seems to call into the android build system which also fails due to the error message, "Unable to resolve project target 'android-7'.
Please advise. Thanks.
Providing a vector to :layout-height
or :layout-width
such as [10 :dp]
leaks the Activity because eventually to-dimension
is called with an Activity Context as a parameter ((.getContext wdg)
), which then calls get-display-metrics
if it gets a vector. get-display-metrics
is memoized, so it keeps a reference to its parameter, the Activity, which then prevents the Activity from getting garbage collected after it finishes.
To reproduce:
To fix, either:
(.getApplicationContext (.getContext wdg))
instead in various parts in traits.clj.get-display-metrics
.Note: For any users out there reading this, it remains safe to provide a vector to :text-size
since it doesn't call to-dimension
.
I'm using 3.2.0, but looking at the latest source the issue should still happen.
Does ref-adapter work?
I'm trying to use ref-adapter, looks very cool, but explodes at runtime with, among other things, the following:
E AndroidRuntime(7164) Caused by: java.lang.ClassNotFoundException: neko.ui.adapters.InterchangeableListAdapter
E AndroidRuntime(7164) at java.lang.Class.classForName(Native Method)
E AndroidRuntime(7164) at java.lang.Class.forName(Class.java:217)
E AndroidRuntime(7164) at java.lang.Class.forName(Class.java:172)
E AndroidRuntime(7164) at neko.ui.adapters$loading__4910__auto__.invoke(adapters.clj:12)
E AndroidRuntime(7164) at neko.ui.adapters__init.load(Unknown Source)
E AndroidRuntime(7164) at neko.ui.adapters__init.<clinit>(Unknown Source)
E AndroidRuntime(7164) ... 36 more
E AndroidRuntime(7164) Caused by: java.lang.NoClassDefFoundError: neko/ui/adapters/InterchangeableListAdapter
E AndroidRuntime(7164) ... 42 more
It's unclear from the stacktrace where exactly the failure is, but it happens at the SplashActivity, and the code which calls ref-adapter is:
(defn schedule-adapter []
(adapters/ref-adapter
(fn [] [:text-view {}])
(fn [_ view _ show]
(on-ui
(.setText view (format-show show))))
schedule/schedule
:future))
My versions of things are:
Leiningen 2.3.4 on Java 1.7.0_03 OpenJDK 64-Bit Server VM
And Android SDK 22.3.
And some project stuff:
; ...
:source-paths ["src/clojure" "src"]
:java-source-paths ["src/java" "gen"]
:plugins [[lein-droid "0.2.2"]]
:javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
:dependencies [[org.clojure-android/clojure "1.5.1-jb" :use-resources true]
[neko/neko "3.0.0"]
[utilza "0.1.53"]
[cheshire "5.3.0"]]
:profiles {:dev {:dependencies [[android/tools.nrepl "0.2.0-bigstack"]
[clojure-complete "0.2.3"]
[compliment "0.0.3"]]
; ...
:android {
:dex-opts ["-JXmx4096M"]
:support-libraries ["v13"] ;; needed for localbroadcast
:target-version "14"
:aot-exclude-ns [clojure.parallel
clojure.core.reducers
; ...
And I'm building with lein-droid doall.
I've tried cleaning with lein clean, and wiping out the old APK on the device.
The device is a TF101 running CM 9.1.
Indeed, I looked into the classes.dex and if I am reading it correctly the class is not in there, though it is referenced:
Virtual methods -
#0 : (in Lneko/ui/adapters$ref_adapter;)
name : 'invoke'
type : '(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;'
access : 0x0001 (PUBLIC)
code -
registers : 13
ins : 4
outs : 5
insns size : 33 16-bit code units
catches : (none)
positions :
0x0000 line=19
locals :
0x0001 - 0x0020 reg=0 this Lneko/ui/adapters$ref_adapter;
0x0002 - 0x0021 reg=1 create_view_fn Ljava/lang/Object;
0x0003 - 0x0021 reg=2 update_view_fn Ljava/lang/Object;
0x0004 - 0x0021 reg=3 ref_type Ljava/lang/Object;
0x0000 - 0x0021 reg=9 this Lneko/ui/adapters$ref_adapter;
#1 : (in Lneko/ui/adapters$ref_adapter;)
name : 'invoke'
type : '(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;'
access : 0x0001 (PUBLIC)
code -
registers : 20
ins : 5
outs : 4
insns size : 310 16-bit code units
catches : (none)
positions :
0x0000 line=19
0x005e line=44
0x0078 line=45
0x009a line=19
locals :
0x004f - 0x0057 reg=5 create_fn Lneko/ui/adapters$ref_adapter$create_fn__2359;
0x0001 - 0x0099 reg=0 this Lneko/ui/adapters$ref_adapter;
0x0078 - 0x0099 reg=6 adapter Lneko/ui/adapters/InterchangeableListAdapter;
0x0057 - 0x009a reg=5 create_fn Ljava/lang/Object;
0x009a - 0x0136 reg=0 this Lneko/ui/adapters$ref_adapter;
0x0003 - 0x0136 reg=1 create_view_fn Ljava/lang/Object;
0x0005 - 0x0136 reg=2 update_view_fn Ljava/lang/Object;
0x0007 - 0x0136 reg=3 ref_type Ljava/lang/Object;
0x0009 - 0x0136 reg=4 access_fn Ljava/lang/Object;
0x0000 - 0x0136 reg=15 this Lneko/ui/adapters$ref_adapter;
source_file_idx : 15306 (adapters.clj)
And, looking in target/classes, there's nothing there either.
find target/ -name '*InterchangeableListAdapter*'
$
So, it looks like this class is not getting compiled at all? Why would that be? Is there something wrong with my toolchain, is there something I have misconfigured, or is something missing from neko?
Is this project defunct?
Using 3.0.0-beta5. I get a NullpointerException when using this (stripped down from your more elaborate example on http://clojure-android.blogspot.de/).
In case it's relevant: MainActivity expands an XML Layout, and it works like a charm when run from
:on-create-options-menu
in defactivity.
(defn MainActivity-onCreateOptionsMenu [this menu]
(make-menu
menu [[:item {:title "First"
:show-as-action :never}]
[:menu {:title "Submenu"
:show-as-action :never}
[:item {:title "Second"}]]
[:group {:id :not-important}
[:item {:title "Third"
:show-as-action :never}]
[:item {:title "Four"
:show-as-action :never}]]]))
Hi there,
I'm looking to create a custom drawing as part of a component. In the Android API it seems I'd subclass view and implement onDraw to draw directly on the canvas. I'm not sure in neko if it's possible to do this without writing my custom component in Java - it seems custom elements need a classname.
Any pointer much appreciated,
Cheers,
Dean
Issue by jjpe from Friday May 31, 2013 at 20:26 GMT
Originally opened as #1
I just tried the steps outlined in Getting Started twice. Both times I can walk through the whole thing, but ant debug install
generates an error:
$ ant debug
:
Buildfile: /home/j/Development/clojure/autonomer/build.xml
-set-mode-check:
-set-debug-files:
-check-env:
[checkenv] Android SDK Tools Revision 22.0.1
[checkenv] Installed at /home/j/Development/adt-bundle-linux-x86_64-20130522/sdk
-setup:
[echo] Project Name: MainActivity
[gettype] Project Type: Application
-set-debug-mode:
-debug-obfuscation-check:
-build-setup:
[getbuildtools] Using latest Build Tools: 17.0.0
[echo] Resolving Build Target for MainActivity...
[gettarget] Project Target: Android 4.0.3
[gettarget] API level: 15
[gettarget] WARNING: No minSdkVersion value set. Application will install on all Android versions.
[echo] ----------
[echo] Creating output directories if needed...
[echo] ----------
[echo] Resolving Dependencies for MainActivity...
[dependency] Library dependencies:
[dependency]
[dependency] ------------------
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
[dependency] API<=15: Adding annotations.jar to the classpath.
[echo] ----------
[echo] Building Libraries with 'debug'...
BUILD FAILED
/home/j/Development/adt-bundle-linux-x86_64-20130522/sdk/tools/ant/build.xml:598: The following error occurred while executing this line:
/home/j/Development/clojure/neko/build.xml:46: sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
Total time: 1 second
local.properties contains a valid path to sdk.dir, I verified that.
The following crashes my activity during start up:
(ns mynamespace.main
(:use [neko.ui.adapters :only [ref-adapter]])
Getting:
E/AndroidRuntime( 680): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 680): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime( 680): at java.lang.Class.forName(Class.java:251)
From cider doing without the line that crashes it:
(use '[neko.ui.adapters :only [ref-adapter]])
gives:
java.lang.ClassNotFoundException: neko.ui.adapters.InterchangeableListAdapter
at java.lang.Class.classForName (Class.java:-2)
java.lang.Class.forName (Class.java:251)
Here is the exception stacktrace whis is helpful as they are https://www.refheap.com/77772
from what I gather something is trying to define a class java.lang.XXX, but what?
I'm trying to use an image in an :image-view
which lives in /res/drawable-*/dummy_image.png
.
When I try to reference that image using android.R$drawable/dummy_image
I see the following exception: Caused by: java.lang.RuntimeException: Unable to find static field: dummy_image in class android.R$drawable
I tried to use :constructor-args
with a View class that has a constructor with two arguments, the second beeing a primitive int.
[:my-view {:constructor-args [256]}
results in following error
java.lang.NoSuchMethodException: <init> [class android.content.Context, class java.lang.Long]
[:my-view {:constructor-args [(int 256)]}
results in following error
java.lang.NoSuchMethodException: <init> [class android.content.Context, class java.lang.Integer]
I believe the only way to support this case, is to add some kind of special syntax or metadata to :constructor-args
.
If I specify a :on-editor-action
in a text-view's map like the following, I get an exception saying there's no such method .setOnEditorAction
.
[:edit-text {:on-editor-action
(fn [view _action _event] ...)}]
I tried :on-editor-action-listener
, but I get the same problem.
I got this to work on lollipop as the issue on clojure-android/clojure but nrepl doesn't start because when I try to connect I get a connection refused error. Is this just temporary or is this an issue? Here's my project.clj https://gist.github.com/rhg/b03df0b3c1f6bd92731f
About a week ago I could run lein droid jar
on the 4.0 branch just fine, but today I tried again after pulling and got this:
/home/artur/Git-Projects/neko/src/java/neko/App.java:17: error: cannot find symbol
DalvikDynamicClassLoader.setContext(this);
^
symbol: method setContext(App)
location: class DalvikDynamicClassLoader
Env:
I want to execute initialization logic in MyApplication.onCreate()
.
I wrote clojure.lang.Var.invoke()
in onCreate()
like this:
public void onCreate() {
Log.v(TAG,"--- onCreate() in ---");
Symbol APPLICATION = Symbol.intern("myapp.application");
REQUIRE.invoke(APPLICATION);
Var ON_CREATE = RT.var("myapp.application", "app-on-create");
ON_CREATE.invoke(MyApplication.this);
}
and got error: java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.Var
app-on-create
calls neko.data.sqlite/get-database
, and it calls neko.data.sqlite/create-helper
function.
But neko.context/context
is unbound at that time. It causes the error.
So, I fixed app-on-create
like this:
(defn app-on-create
[this]
(do
(if (not (bound? #'neko.context/context))
(alter-var-root #'neko.context/context (constantly this)))
; and my code...
This code works...but the solution is correct?
As it says in the title, I changed my app to use API level 10 and my previously fully working splash stopped changin 'Application Name' to the app's name. As an example on my account there is github.com/rhg/sandbox which displays the bug. Thank you for saving me from the horrors of java (well partly).
I am currently looking into adding better content provider support into Neko. It would be nice if the Cursor support could be more generic so that it can support all Cursor objects, regardless of source.
Issue by Illotus from Sunday Jun 02, 2013 at 12:26 GMT
Originally opened as #2
Hi,
First thanks for lein-droid and neko, both have rejuvenated my interest in android programming.
My problem is that I'm not getting get-service to work with :location, but instead get "object is not an instance of the declaring class" exception. (get-service :alert) leads to "Unable to find static field: ALERT_SERVICE in class android.content.Context". Any ideas what I am doing wrong?
(ns com.illotus.gpsmeter.main
(:use [neko.resource :only [get-string get-resource]]
[neko.activity :only [defactivity set-content-view!]]
[neko.threading :only [on-ui]]
[neko.ui :only [make-ui]]
[neko.application :only [defapplication]]
[neko.activity :only [defactivity set-content-view!]]
[neko.notify :only [toast]]
[neko.context :only [context get-service]])
(:import [com.illotus.gpsmeter R$string]
[android.location.Location]
[android.location.LocationManager]
[android.location.Criteria]
[android.location.LocationProvider]))
(defapplication com.illotus.gpsmeter.Application)
(def gps (get-service :layout-inflater))
(defn get-loc [] (.getLastKnownLocation gps (.getBestProvider gps (.setAccuracy (new Criteria) Criteria/ACCURACY_FINE) true)))
(defn toast-me [view] (toast (str (get-loc))))
(defn get-main-view [a]
(fn [this bundle]
(on-ui
(set-content-view! a
(let [view
(make-ui
[:linear-layout {:orientation :vertical
:layout-width :fill
:layout-height :fill}
[:button {:layout-width :fill
:layout-height :wrap
:text (get-string :mark_throwing_spot)
:on-click toast-me
}]
[:linear-layout {:layout-width :fill
:layout-height :wrap
:orientation :vertical}
[:text-view {:layout-width :wrap
:layout-height :wrap
:text (get-string :current_distance) }]
[:text-view {:layout-width :wrap
:layout-height :wrap
:text (get-string :zero_distance)}]
[:text-view {:layout-width :wrap
:layout-height :wrap
:text (get-string :last_measured_distance)}]
[:text-view {:layout-width :wrap
:layout-height :wrap
:text (get-string :zero_distance)}]]
[:button {:layout-width :fill
:layout-height :wrap
:text (get-string :show_current_session_throws)
:on-click toast-me}]
[:button {:layout-width :fill
:layout-height :wrap
:text (get-string :mark_distance)
:on-click toast-me}]])]
view)))))
(defactivity com.illotus.gpsmeter.GPSMeter
:def a
:on-create
(get-main-view a))
Results in:
Generating R.java...
Compiling 1 source files to /home/olli/webclj/android/gpsmeter/target/classes
Compiling Clojure files...
Build type: debug, dynamic compilation: enabled, remote REPL: enabled.
Compiling clojure.java.browse
Compiling neko.ui.listview
Compiling clojure.data
Compiling clojure.tools.nrepl.middleware.interruptible-eval
Compiling clojure.tools.nrepl.ack
Compiling clojure.tools.nrepl.server
Compiling clojure.tools.nrepl.misc
Compiling neko.init.options
Compiling neko.listeners.adapter-view
Compiling neko.doc
Compiling neko.resource
Compiling clojure.core.protocols
Compiling neko.-utils
Compiling clojure.tools.nrepl.helpers
Compiling clojure.tools.nrepl.cmdline
Compiling clojure.zip
Compiling neko.init
Compiling neko.listeners.text-view
Compiling clojure.java.shell
Compiling neko.activity
Compiling clojure.test
Compiling clojure.test.tap
Compiling clojure.test.junit
Compiling neko.data
Compiling clojure.template
Compiling com.illotus.gpsmeter.main
Exception in thread "main" java.lang.IllegalArgumentException: object is not an instance of declaring class, compiling:(main.clj:18)
at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1435)
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:398)
at clojure.lang.Compiler.compile1(Compiler.java:7035)
at clojure.lang.Compiler.compile(Compiler.java:7097)
at clojure.lang.RT.compile(RT.java:412)
at clojure.lang.RT.load(RT.java:452)
at clojure.lang.RT.load(RT.java:425)
at clojure.core$load$fn__4890.invoke(core.clj:5415)
at clojure.core$load.doInvoke(core.clj:5414)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5227)
at clojure.core$compile$fn__4895.invoke(core.clj:5426)
at clojure.core$compile.invoke(core.clj:5425)
at user$eval5.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6511)
at clojure.lang.Compiler.eval(Compiler.java:6501)
at clojure.lang.Compiler.eval(Compiler.java:6477)
at clojure.core$eval.invoke(core.clj:2797)
at clojure.main$eval_opt.invoke(main.clj:302)
at clojure.main$initialize.invoke(main.clj:321)
at clojure.main$null_opt.invoke(main.clj:354)
at clojure.main$main.doInvoke(main.clj:432)
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.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Compiler$InstanceMethodExpr.eval(Compiler.java:1428)
... 26 more
Compilation failed.
How to reproduce:
clojure.lang.Var$Unbound cannot be cast to android.content.Context
It seems that the SplashActivity's static firstLaunch field is still in its previous state, causing the splash activity to directly proceed(), without calling neko.init/init again.
I'm filing this against neko rather than lein-droid, because I'd like to propose that the use of neko.context/context should be completely removed from the library. It appears to me that the current solution is neither idiomatic for Clojure nor for Android ...
Update 2014-03-14: You may have to implement a sticky service that's restarted once the starting activity is destroyed to reproduce.
First of all, thanks for the great and constant work you put in neko. I wanted to get in touch with android development in clojure. But after creating a project as described, using:
$> lein droid new clojuroid org.stuff.clojuroid :activity MyActivity :target-sdk 19 :app-name ClojureMeetsAndroid
I try to build it with lein droid build
and get an OutOfMemory exception:
Creating DEX....
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: Java heap space
at com.android.dx.cf.code.Frame.copy(Frame.java:98)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:697)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:653)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:266)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:282)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
at com.android.dx.command.dexer.Main.processClass(Main.java:682)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
I tried different neko versions, increasing jvm memory, cleaned up my profiles.clj. I even tried those steps on different machines. Non of my actions could prevent this from happening.
What am I doing wrong?
I use:
java 1.7.0_21,
neko 3.x
lein-droid 0.2.3
leiningen 2.2.0
I'm having problems using the TextClock widget with neko/lein-droid. Using the older, deprecated DigitalClock works fine. The code compiles but when I run it I get a ClassNotFoundException. I've looked at issue #29 and tried changing the JDK version but that doesn't work. I've also tried fiddling with the Clojure version.
Here's the code:
(ns org.stuff.clockradio.main
(:use [neko.activity :only [defactivity set-content-view!]]
[neko.threading :only [on-ui]]
[neko.ui.mapping :only [defelement]]
[neko.ui :only [make-ui]])
(:import [android.view View]
[android.widget TextView]
[android.widget TextClock]
android.app.Activity ))
(defelement :digital-clock
:classname android.widget.TextClock
:inherits :text-view
)
(def clock-layout [:linear-layout {:orientation :vertical}
[:digital-clock {:text-size 40} ]])
(defactivity org.stuff.clockradio.MainActivity
:def a
:on-create
(fn [this bundle]
(on-ui
(set-content-view! a
(make-ui clock-layout)))))
Here's the project.clj file:
(defproject clockradio/clockradio "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.4.3"
:global-vars {*warn-on-reflection* true}
:source-paths ["src/clojure" "src"]
:java-source-paths ["src/java" "gen"]
:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]
:dependencies [[compliment "0.0.3"]
[org.clojure/tools.nrepl "0.2.4"]
[org.clojure/java.classpath "0.2.0"]
[org.clojure/tools.namespace "0.2.5"]
[org.clojure/tools.trace "0.7.8"]
[neko/neko "3.0.2"]]
:profiles {:android-dev
{:dependencies [ [org.clojure-android/clojure "1.6.0-RC1" :use-resources true]
[cider/cider-nrepl "0.7.0"]
]
:repl-options {:nrepl-middleware
[cider.nrepl.middleware.classpath/wrap-classpath
cider.nrepl.middleware.complete/wrap-complete
cider.nrepl.middleware.info/wrap-info
cider.nrepl.middleware.inspect/wrap-inspect
cider.nrepl.middleware.macroexpand/wrap-macroexpand
cider.nrepl.middleware.resource/wrap-resource
cider.nrepl.middleware.stacktrace/wrap-stacktrace
cider.nrepl.middleware.test/wrap-test
cider.nrepl.middleware.trace/wrap-trace
cider.nrepl.middleware.undef/wrap-undef]}
: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
:build-tools-version "19.1.0"
:target-version "19"
:aot-exclude-ns ["clojure.parallel" "clojure.core.reducers"]})
Here's the output from DEBUG=1 lein droid doall:
charles@charles-ALTO:~/code/dev/android/clockradio/src/clojure/org/stuff/clockradio$ DEBUG=1 lein droid doall
Leiningen's classpath: /home/charles/.lein/self-installs/leiningen-2.4.3-standalone.jar
Applying task droid to [doall]
Generating R.java...
/home/charles/code/android-sdk-linux/build-tools/19.1.0/aapt package --auto-add-overlay -f -m -M /home/charles/code/dev/android/clockradio/AndroidManifest.xml -S /home/charles/code/dev/android/clockradio/target/res -S /home/charles/code/dev/android/clockradio/res -I /home/charles/code/android-sdk-linux/platforms/android-19/android.jar -J /home/charles/code/dev/android/clockradio/gen --generate-dependencies
Applying task javac to nil
Running javac with [-target 1.7 -source 1.7 -Xlint:-options @/tmp/.leiningen-cmdline5306163538174791683.tmp]
Compiling 1 source files to /home/charles/code/dev/android/clockradio/target/classes
Applying task compile to nil
All namespaces already AOT compiled.
Running javac with [-target 1.7 -source 1.7 -Xlint:-options @/tmp/.leiningen-cmdline2210937812192575873.tmp]
Compiling Clojure files...
Project classpath: (/home/charles/code/android-sdk-linux/tools/support/annotations.jar /home/charles/code/android-sdk-linux/platforms/android-19/android.jar /home/charles/code/dev/android/clockradio/test /home/charles/code/dev/android/clockradio/src/clojure /home/charles/code/dev/android/clockradio/src /home/charles/code/dev/android/clockradio/resources /home/charles/code/dev/android/clockradio/target/classes /home/charles/.m2/repository/org/clojure/tools.trace/0.7.8/tools.trace-0.7.8.jar /home/charles/.m2/repository/org/tcrawley/dynapath/0.2.3/dynapath-0.2.3.jar /home/charles/.m2/repository/org/clojure/java.classpath/0.2.0/java.classpath-0.2.0.jar /home/charles/.m2/repository/compliment/compliment/0.0.3/compliment-0.0.3.jar /home/charles/.m2/repository/neko/neko/3.0.2/neko-3.0.2.jar /home/charles/.m2/repository/org/clojure-android/clojure/1.6.0-RC1/clojure-1.6.0-RC1.jar /home/charles/.m2/repository/cider/cider-nrepl/0.7.0/cider-nrepl-0.7.0.jar /home/charles/.m2/repository/org/clojure/tools.nrepl/0.2.4/tools.nrepl-0.2.4.jar /home/charles/.m2/repository/org/clojure/tools.namespace/0.2.5/tools.namespace-0.2.5.jar /home/charles/.m2/repository/cljs-tooling/cljs-tooling/0.1.3/cljs-tooling-0.1.3.jar)
Build type: debug, dynamic compilation: enabled, remote REPL: enabled.
Applying task javac to nil
Running javac with [-target 1.7 -source 1.7 -Xlint:-options @/tmp/.leiningen-cmdline5259557351238220923.tmp]
Compiling neko.compliment.ui-widgets-and-attributes
Compiling neko.debug
Compiling clojure.java.shell
Compiling cljs-tooling.info
Compiling neko.application
Compiling clojure.tools.namespace.find
Compiling clojure.reflect
Compiling cider.nrepl.middleware.util.cljs
Compiling clojure.tools.nrepl.transport
Compiling neko.log
Compiling clojure.java.javadoc
Compiling clojure.zip
Compiling clojure.xml
Compiling dynapath.dynamic-classpath
Compiling cider.nrepl.middleware.util.inspect
Compiling neko.threading
Compiling cljs-tooling.util.misc
Compiling compliment.core
Compiling cider.nrepl.middleware.trace
Compiling neko.ui.menu
Compiling neko.ui.traits
Compiling clojure.stacktrace
Compiling neko.find-view
Compiling neko.init
Compiling cider.nrepl
Compiling neko.ui.listview
Compiling clojure.tools.namespace.dir
Compiling neko.ui.mapping
Compiling clojure.tools.nrepl.server
Compiling cider.nrepl.middleware.util.java
Compiling neko.listeners.dialog
Compiling cljs-tooling.util.analysis
Compiling neko.action-bar
Compiling clojure.inspector
Compiling neko.context
Compiling clojure.tools.nrepl.ack
Compiling neko.activity
Compiling clojure.tools.namespace.reload
Compiling clojure.tools.namespace.file
Compiling clojure.test
Compiling cider-nrepl.plugin
Compiling clojure.core.protocols
Compiling neko.-utils
Compiling clojure.java.browse
Compiling cider.nrepl.middleware.complete
Compiling clojure.tools.namespace.move
Compiling cider.nrepl.middleware.util.java.parser
Compiling clojure.tools.nrepl.bencode
Compiling org.stuff.clockradio.main
Compiling clojure.tools.nrepl.middleware.load-file
Compiling neko.data.sqlite
Compiling cljs-tooling.complete
Compiling compliment.sources
Compiling cider.nrepl.middleware.macroexpand
Compiling clojure.core
Compiling cider.nrepl.middleware.stacktrace
Compiling clojure.tools.nrepl.middleware
Compiling clojure.set
Compiling neko.listeners.search-view
Compiling cider.nrepl.middleware.classpath
Compiling neko.doc
Compiling neko.compilation
Compiling clojure.tools.namespace.dependency
Compiling cider.nrepl.middleware.util.misc
Compiling clojure.java.classpath
Compiling clojure.tools.nrepl.middleware.pr-values
Compiling cider.nrepl.middleware.apropos
Compiling clojure.main
Compiling dynapath.util
Compiling clojure.tools.namespace.parse
Compiling cider.nrepl.middleware.resource
Compiling compliment.utils
Compiling clojure.tools.namespace
Compiling neko.compliment.android-resources
Compiling clojure.test.tap
Compiling clojure.tools.nrepl.misc
Compiling cider.nrepl.middleware.test
Compiling compliment.sources.ns-mappings
Compiling clojure.pprint
Compiling cider.nrepl.middleware.inspect
Compiling clojure.java.browse-ui
Compiling clojure.uuid
Compiling clojure.tools.trace
Compiling clojure.edn
Compiling neko.dialog.alert
Compiling neko.listeners.view
Compiling clojure.java.io
Compiling compliment.sources.namespaces-and-classes
Compiling neko.data
Compiling compliment.context
Compiling clojure.instant
Compiling neko.notify
Compiling clojure.tools.nrepl.helpers
Compiling clojure.tools.nrepl.cmdline
Compiling clojure.repl
Compiling cider.nrepl.middleware.info
Compiling clojure.string
Compiling clojure.data
Compiling clojure.test.junit
Compiling clojure.walk
Compiling clojure.tools.namespace.repl
Compiling clojure.tools.namespace.track
Compiling clojure.tools.nrepl
Compiling neko.listeners.text-view
Compiling clojure.tools.nrepl.middleware.session
Compiling neko.ui
Compiling neko.ui.adapters
Compiling compliment.sources.class-members
Compiling neko.resource
Compiling clojure.tools.nrepl.middleware.interruptible-eval
Compiling dynapath.defaults
Compiling clojure.template
Compiling neko.listeners.adapter-view
Compilation succeeded.
Creating DEX....
/home/charles/code/android-sdk-linux/build-tools/19.1.0/dx -JXmx4096M --dex --no-optimize --output /home/charles/code/dev/android/clockradio/target/classes.dex /home/charles/code/dev/android/clockradio/target/classes /home/charles/code/android-sdk-linux/tools/support/annotations.jar /home/charles/.m2/repository/org/clojure/tools.trace/0.7.8/tools.trace-0.7.8.jar /home/charles/.m2/repository/org/tcrawley/dynapath/0.2.3/dynapath-0.2.3.jar /home/charles/.m2/repository/org/clojure/java.classpath/0.2.0/java.classpath-0.2.0.jar /home/charles/.m2/repository/compliment/compliment/0.0.3/compliment-0.0.3.jar /home/charles/.m2/repository/neko/neko/3.0.2/neko-3.0.2.jar /home/charles/.m2/repository/org/clojure-android/clojure/1.6.0-RC1/clojure-1.6.0-RC1.jar /home/charles/.m2/repository/cider/cider-nrepl/0.7.0/cider-nrepl-0.7.0.jar /home/charles/.m2/repository/org/clojure/tools.nrepl/0.2.4/tools.nrepl-0.2.4.jar /home/charles/.m2/repository/org/clojure/tools.namespace/0.2.5/tools.namespace-0.2.5.jar /home/charles/.m2/repository/cljs-tooling/cljs-tooling/0.1.3/cljs-tooling-0.1.3.jar
Crunching resources...
/home/charles/code/android-sdk-linux/build-tools/19.1.0/aapt crunch -v -S /home/charles/code/dev/android/clockradio/res -C /home/charles/code/dev/android/clockradio/target/res
Crunching PNG Files in source dir: /home/charles/code/dev/android/clockradio/res
To destination dir: /home/charles/code/dev/android/clockradio/target/res
Packaging resources...
/home/charles/code/android-sdk-linux/build-tools/19.1.0/aapt package --no-crunch -f --debug-mode --auto-add-overlay -M /home/charles/code/dev/android/clockradio/AndroidManifest.xml -S /home/charles/code/dev/android/clockradio/target/res -S /home/charles/code/dev/android/clockradio/res -A /home/charles/code/dev/android/clockradio/assets -I /home/charles/code/android-sdk-linux/platforms/android-19/android.jar -F /home/charles/code/dev/android/clockradio/target/clockradio.ap_ --generate-dependencies
Creating APK...
Adding resource libraries: (#<File /home/charles/.m2/repository/org/clojure-android/clojure/1.6.0-RC1/clojure-1.6.0-RC1.jar>)
Signing APK with /home/charles/.android/debug.keystore ...
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore /home/charles/.android/debug.keystore -storepass android -keypass android /home/charles/code/dev/android/clockradio/target/clockradio-debug-unaligned.apk androiddebugkey
jar signed.
Warning:
No -tsa or -tsacert is provided and this jar is not timestamped. Without a timestamp, users may not be able to validate this jar after the signer certificate's expiration date (2042-06-26) or after any future revocation date.
Aligning APK...
/home/charles/code/android-sdk-linux/tools/zipalign 4 /home/charles/code/dev/android/clockradio/target/clockradio-debug-unaligned.apk /home/charles/code/dev/android/clockradio/target/clockradio-debug.apk
/home/charles/code/android-sdk-linux/platform-tools/adb devices
List of devices attached
VS870_4G-a2b68b4 device
Installing APK...
/home/charles/code/android-sdk-linux/platform-tools/adb -s VS870_4G-a2b68b4 install -r /home/charles/code/dev/android/clockradio/target/clockradio-debug.apk
1700 KB/s (2557695 bytes in 1.468s)
pkg: /data/local/tmp/clockradio-debug.apk
Success
Launching APK...
/home/charles/code/android-sdk-linux/platform-tools/adb -s VS870_4G-a2b68b4 shell am start -n org.stuff.clockradio/.SplashActivity
Starting: Intent { cmp=org.stuff.clockradio/.SplashActivity }
Binding device port 9999 to local port 9999 ...
And here is the stack dump:
E/AndroidRuntime(11636): FATAL EXCEPTION: Thread-217122
E/AndroidRuntime(11636): java.lang.ExceptionInInitializerError
E/AndroidRuntime(11636): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(11636): at java.lang.Class.forName(Class.java:217)
E/AndroidRuntime(11636): at java.lang.Class.forName(Class.java:172)
E/AndroidRuntime(11636): at org.stuff.clockradio.SplashActivity$1.run(SplashActivity.java:65)
E/AndroidRuntime(11636): at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime(11636): Caused by: java.lang.ExceptionInInitializerError
E/AndroidRuntime(11636): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(11636): at java.lang.Class.forName(Class.java:217)
E/AndroidRuntime(11636): at clojure.lang.RT.loadClassForName(RT.java:2140)
E/AndroidRuntime(11636): at clojure.lang.RT.load(RT.java:455)
E/AndroidRuntime(11636): at clojure.lang.RT.load(RT.java:436)
E/AndroidRuntime(11636): at clojure.core$load$fn__5066.invoke(core.clj:5640)
E/AndroidRuntime(11636): at clojure.core$load.doInvoke(core.clj:5640)
E/AndroidRuntime(11636): at clojure.lang.RestFn.invoke(RestFn.java:408)
E/AndroidRuntime(11636): at clojure.lang.Var.invoke(Var.java:379)
E/AndroidRuntime(11636): at org.stuff.clockradio.MainActivity.(Unknown Source)
E/AndroidRuntime(11636): ... 5 more
E/AndroidRuntime(11636): Caused by: java.lang.ClassNotFoundException: android.widget.TextClock
E/AndroidRuntime(11636): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(11636): at java.lang.Class.forName(Class.java:217)
E/AndroidRuntime(11636): at java.lang.Class.forName(Class.java:172)
E/AndroidRuntime(11636): at org.stuff.clockradio.main__init.__init0(Unknown Source)
E/AndroidRuntime(11636): at org.stuff.clockradio.main__init.(Unknown Source)
E/AndroidRuntime(11636): ... 15 more
E/AndroidRuntime(11636): Caused by: java.lang.NoClassDefFoundError: android/widget/TextClock
E/AndroidRuntime(11636): ... 20 more
E/AndroidRuntime(11636): Caused by: java.lang.ClassNotFoundException: android.widget.TextClock
E/AndroidRuntime(11636): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime(11636): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(11636): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(11636): ... 20 more
The ref-adapter example use case, with (make-ui [:text-view {}])
as the view-creation function breaks with
android.view.ViewGroup$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
It seems that make-ui defaults to setting ViewGroup$LayoutParams on views created without container or with an unknown container, which makes them unattachable to Listviews subsequently?
(debug/safe-for-ui
(view/find-view (debug/*a) ::playing-button))
returns nil
but the view that is set at onCreate time definitely has an element with that id, and I can see it displayed. When run from inside the program (rather than the repl), using this instead of (debug/*a), it also returns nil.
Interestingly, in attempting to debug this, I tried this from a REPL:
(debug/safe-for-ui
(activity/get-decor-view (debug/*a)))
And got a strange
#object[com.android.internal.policy.impl.PhoneWindow$DecorView 0xa104b800 "com.android.internal.policy.impl.PhoneWindow$DecorView@a104b800"]
returned instead of my view.
I'm not sure what's going on here.
Hi,
When using this dependency which is laid down by the droid template [org.clojure-android/tools.nrepl "0.2.10"]
, I would get the following error:
Could not transfer artifact org.clojure-android:tools.nrepl:pom:0.2.10 from/to clojars (https://clojars.org/repo/): Connect to clojars.org:443 [clojars.org/38.0.60.2] failed: Connection timed out
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
Using this other dependency resolved the problem: [org.clojure-android/tools.nrepl "0.2.6-lollipop"]
Let me know if you need some more info. I'm unsure of what could be causing this problem. I could always be doing something dumb :)
Regards,
Callum
Hello, I'm trying to use neko(3.1.0-SNAPSHOT / 3.0.2) on emulator/real device Nexus 5 with latest stable version of Android KitKat. On dalvik runtime my application with neko loads just fine, but on ART runtime I get an error that is posted in the end of the post. I did a little bit of searching and it seems that function neko.compilation.clear-cache is rejected by Android verifier because 'it is too complex'. Any response to this would be highly appreciated. Thanks, Martin.
08-25 13:46:13.603 3496-3512/kauer.martin.grader E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-118
Process: kauer.martin.grader, PID: 3496
java.lang.VerifyError: Rejecting class neko.compilation$clear_cache because it failed compile-time verification (declaration of 'neko.compilation$clear_cache' appears in /data/app/kauer.martin.grader-2.apk)
at neko.compilation__init.load(Unknown Source)
at neko.compilation__init.(Unknown Source)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:305)
at clojure.lang.RT.loadClassForName(RT.java:2140)
at clojure.lang.RT.load(RT.java:455)
at clojure.lang.RT.load(RT.java:436)
at clojure.core$load$fn__5066.invoke(core.clj:5640)
at clojure.core$load.doInvoke(core.clj:5640)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5446)
at clojure.core$load_lib$fn__5015.invoke(core.clj:5485)
at clojure.core$load_lib.doInvoke(core.clj:5485)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:626)
at clojure.core$load_libs.doInvoke(core.clj:5528)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:626)
at clojure.core$require.doInvoke(core.clj:5545)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at neko.init$loading__4958__auto__.invoke(init.clj:12)
at neko.init__init.load(Unknown Source)
at neko.init__init.(Unknown Source)
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:305)
at clojure.lang.RT.loadClassForName(RT.java:2140)
at clojure.lang.RT.load(RT.java:455)
at clojure.lang.RT.load(RT.java:436)
at clojure.core$load$fn__5066.invoke(core.clj:5640)
at clojure.core$load.doInvoke(core.clj:5640)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5446)
at clojure.core$load_lib$fn__5015.invoke(core.clj:5485)
at clojure.core$load_lib.doInvoke(core.clj:5485)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:626)
at clojure.core$load_libs.doInvoke(core.clj:5524)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:626)
at clojure.core$require.doInvoke(core.clj:5545)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:379)
at kauer.martin.grader.SplashActivity$1.run(SplashActivity.java:59)
at java.lang.Thread.run(Thread.java:811)
;;;;;;; this gives IllegalArgumentException while compiling
(def ui (make-ui [:linear-layout {}
[:text-view {:text "doh"}]]))
(defactivity foo.bar.MainActivity
:def a
:on-create
(fn [this bundle]
(on-ui
(set-content-view! a
(make-ui [:linear-layout {}
[:text-view {:text "Hello from Clojure!"}]])))))
;;;;;; ^^ this does not - what's the deal??
This does not occur when I disable aot for the given namespace.
PS. I'm not really sure whether it's really a neko issue, or whether maybe it belongs to lein-droid or whether is it beyond the scope of clojure-android, I was just unable to figure out the cause and I decided to report it here.
the tabs will be appended in the bar whenever the setup-aciton-bar is evaluated instead of rerender in the REPL?
Is it an issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.