ClassNotFoundException: android.widget.TextClock
Closed this issue · 3 comments
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 ...
/home/charles/code/android-sdk-linux/platform-tools/adb -s VS870_4G-a2b68b4 forward tcp:9999 tcp: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
Device version is 16 (4.1.2)
Hello neveu,
I've seen your message just now. So did you resolve the issue and what was wrong?
@neveu, can you please tell if you still have this problem? Is it because android.widget.TextClock
was added in API 17?