Closed thash closed 10 years ago
Hello!
No, release build does not require nrepl. What I see is that neko.init/init
still tries to start Nrepl even in the release mode. That shouldn't happen. Can you please try to do this and post the output here.
lein clean
lein droid release
Hi! I appreciate your quick reply.
$ lein clean
$ DEBUG=1 lein droid release
And I got following output. ;; "hash" is my username.
Leiningen's classpath: :/usr/local/Cellar/leiningen/2.3.2/libexec/leiningen-2.3.2-standalone.jar
Applying task droid to (release)
Generating R.java...
/Users/hash/work/android/sdk/build-tools/17.0.0/aapt package --auto-add-overlay -f -m -M /Users/hash/work/clojure-android-release-test/AndroidManifest.xml -S /Users/hash/work/clojure-android-release-test/target/res -S /Users/hash/work/clojure-android-release-test/res -I /Users/hash/work/android/sdk/platforms/android-15/android.jar -J /Users/hash/work/clojure-android-release-test/gen --generate-dependencies
Applying task javac to nil
Running javac with [-target 1.6 -source 1.6 -Xlint:-options @/var/folders/74/j9q4wrlx40zg637qmnfz4tr40000gn/T/.leiningen-cmdline4532716289113976246.tmp]
Compiling 2 source files to /Users/hash/work/clojure-android-release-test/target/classes
Applying task compile to nil
All namespaces already AOT compiled.
Running javac with [-target 1.6 -source 1.6 -Xlint:-options @/var/folders/74/j9q4wrlx40zg637qmnfz4tr40000gn/T/.leiningen-cmdline7253466900894178916.tmp]
Compiling Clojure files...
Project classpath: (/Users/hash/work/android/sdk//tools/support/annotations.jar /Users/hash/work/android/sdk/platforms/android-15/android.jar /Users/hash/work/clojure-android-release-test/test /Users/hash/work/clojure-android-release-test/src/clojure /Users/hash/work/clojure-android-release-test/src /Users/hash/work/clojure-android-release-test/resources /Users/hash/work/clojure-android-release-test/target/classes /Users/hash/.m2/repository/org/clojure-android/clojure/1.5.1-jb/clojure-1.5.1-jb.jar /Users/hash/.m2/repository/neko/neko/3.0.0-preview3/neko-3.0.0-preview3.jar)
Build type: release, dynamic compilation: disabled, remote REPL: disabled.
Applying task javac to nil
Running javac with [-target 1.6 -source 1.6 -Xlint:-options @/var/folders/74/j9q4wrlx40zg637qmnfz4tr40000gn/T/.leiningen-cmdline4602477675686429641.tmp]
Compiling com.memerelics.release_test.main
Reflection warning, neko/init.clj:77:62 - reference to field getPackageName can't be resolved.
Reflection warning, neko/ui/traits.clj:206:5 - call to setMargins can't be resolved.
Reflection warning, neko/ui/traits.clj:281:12 - call to android.widget.RelativeLayout$LayoutParams ctor can't be resolved.
Reflection warning, neko/ui/traits.clj:304:12 - call to android.widget.AbsListView$LayoutParams ctor can't be resolved.
Compiling clojure.core.protocols
Compiling neko.init
Compiling clojure.string
Compiling clojure.core
Compiling clojure.java.io
Compilation succeeded.
Creating DEX....
/Users/hash/work/android/sdk/build-tools/17.0.0/dx --dex --output /Users/hash/work/clojure-android-release-test/target/classes.dex /Users/hash/work/clojure-android-release-test/target/classes /Users/hash/work/android/sdk//tools/support/annotations.jar /Users/hash/.m2/repository/org/clojure-android/clojure/1.5.1-jb/clojure-1.5.1-jb.jar /Users/hash/.m2/repository/neko/neko/3.0.0-preview3/neko-3.0.0-preview3.jar
Crunching resources...
/Users/hash/work/android/sdk/build-tools/17.0.0/aapt crunch -v -S /Users/hash/work/clojure-android-release-test/res -C /Users/hash/work/clojure-android-release-test/target/res
Crunching PNG Files in source dir: /Users/hash/work/clojure-android-release-test/res
To destination dir: /Users/hash/work/clojure-android-release-test/target/res
Packaging resources...
/Users/hash/work/android/sdk/build-tools/17.0.0/aapt package --no-crunch -f --auto-add-overlay -M /Users/hash/work/clojure-android-release-test/AndroidManifest.xml -S /Users/hash/work/clojure-android-release-test/target/res -S /Users/hash/work/clojure-android-release-test/res -A /Users/hash/work/clojure-android-release-test/assets -I /Users/hash/work/android/sdk/platforms/android-15/android.jar -F /Users/hash/work/clojure-android-release-test/target/clojure-android-release-test.ap_ --generate-dependencies
Creating APK...
Adding resource libraries: (#<File /Users/hash/.m2/repository/org/clojure-android/clojure/1.5.1-jb/clojure-1.5.1-jb.jar>)
Signing APK...
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore /Users/hash/.keystore -storepass hogehoge -keypass hogehoge /Users/hash/work/clojure-android-release-test/target/clojure-android-release-test-unaligned.apk test
Aligning APK...
/Users/hash/work/android/sdk/tools/zipalign 4 /Users/hash/work/clojure-android-release-test/target/clojure-android-release-test-unaligned.apk /Users/hash/work/clojure-android-release-test/target/clojure-android-release-test.apk
/Users/hash/work/android/sdk/platform-tools/adb devices
List of devices attached
d2066563 device
Installing APK...
/Users/hash/work/android/sdk/platform-tools/adb -s d2066563 install -r /Users/hash/work/clojure-android-release-test/target/clojure-android-release-test.apk
6213 KB/s (1748866 bytes in 0.274s)
pkg: /data/local/tmp/clojure-android-release-test.apk
Success
Launching APK...
/Users/hash/work/android/sdk/platform-tools/adb -s d2066563 shell am start -n com.memerelics.release_test/.SplashActivity
Starting: Intent { cmp=com.memerelics.release_test/.SplashActivity }
Binding device port 9999 to local port 9999 ...
/Users/hash/work/android/sdk/platform-tools/adb -s d2066563 forward tcp:9999 tcp:9999
And it's a stack trace from logcat.
E/AndroidRuntime( 1205): java.io.FileNotFoundException: Could not locate clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on classpath:
E/AndroidRuntime( 1205): at clojure.lang.RT.load(RT.java:468)
E/AndroidRuntime( 1205): at clojure.lang.RT.load(RT.java:436)
E/AndroidRuntime( 1205): at clojure.core$load$fn__5018.invoke(core.clj:5529)
E/AndroidRuntime( 1205): at clojure.core$load.doInvoke(core.clj:5529)
E/AndroidRuntime( 1205): at clojure.lang.RestFn.invoke(RestFn.java:408)
E/AndroidRuntime( 1205): at clojure.core$load_one.invoke(core.clj:5336)
E/AndroidRuntime( 1205): at clojure.core$load_lib$fn__4967.invoke(core.clj:5374)
E/AndroidRuntime( 1205): at clojure.core$load_lib.doInvoke(core.clj:5374)
E/AndroidRuntime( 1205): at clojure.lang.RestFn.applyTo(RestFn.java:142)
E/AndroidRuntime( 1205): at clojure.core$apply.invoke(core.clj:619)
E/AndroidRuntime( 1205): at clojure.core$load_libs.doInvoke(core.clj:5413)
E/AndroidRuntime( 1205): at clojure.lang.RestFn.applyTo(RestFn.java:137)
E/AndroidRuntime( 1205): at clojure.core$apply.invoke(core.clj:621)
E/AndroidRuntime( 1205): at clojure.core$use.doInvoke(core.clj:5498)
E/AndroidRuntime( 1205): at clojure.lang.RestFn.invoke(RestFn.java:408)
E/AndroidRuntime( 1205): at neko.init$start_repl.doInvoke(init.clj:36)
E/AndroidRuntime( 1205): at clojure.lang.RestFn.applyTo(RestFn.java:137)
E/AndroidRuntime( 1205): at clojure.core$apply.invoke(core.clj:621)
E/AndroidRuntime( 1205): at neko.init$init.doInvoke(init.clj:80)
E/AndroidRuntime( 1205): at clojure.lang.RestFn.invoke(RestFn.java:410)
E/AndroidRuntime( 1205): at clojure.lang.Var.invoke(Var.java:415)
E/AndroidRuntime( 1205): at com.memerelics.release_test.SplashActivity$1.run(SplashActivity.java:62)
E/AndroidRuntime( 1205): at java.lang.Thread.run(Thread.java:856)
Riiight, I changed the method of interaction between lein-droid and Neko somewhere at that point.
Let's try to solve this differently. You are using neko 3.0.0
, right? Try building the project with lein-droid 0.2.0
. Don't create a new project, just update your profiles.clj
to use newer lein-droid and try building a release again.
Sidenote: you should really pick a much bigger validity term for your release key. Having a valid release key (that you will eventually use in Google's Play Market) is the only way to update the application that was once signed with this key. So in your case, if you put something on the market with this key, in a year you won't be able to update that app.
No, I was using neko 3.0.0-preview3
because I generated the project with lein-droid 0.2.0-preview4
. Now I'm trying to build it with neko 3.0.0
and lein-droid 0.2.0
instead.
;; ~/.lein/profiles.clj
{:user {:plugins [
- [lein-droid "0.2.0-preview4"]
+ [lein-droid "0.2.0"]
;; project.clj
:dependencies [[org.clojure-android/clojure "1.5.1-jb" :use-resources true]
- [neko/neko "3.0.0-preview3"]]
+ [neko/neko "3.0.0"]]
;; Here's my whole project.clj => https://gist.github.com/memerelics/8329858
Then tried release build, but compilation failed... It seems not to be able to resolve activity defined in defactivity
?
$ lein clean
$ DEBUG=1 lein droid release
Leiningen's classpath: :/usr/local/Cellar/leiningen/2.3.2/libexec/leiningen-2.3.2-standalone.jar
Applying task droid to (release)
Generating R.java...
/Users/hash/work/android/sdk/build-tools/17.0.0/aapt package --auto-add-overlay -f -m -M /Users/hash/work/clojure-android-release-test/AndroidManifest.xml -S /Users/hash/work/clojure-android-release-test/target/res -S /Users/hash/work/clojure-android-release-test/res -I /Users/hash/work/android/sdk/platforms/android-15/android.jar -J /Users/hash/work/clojure-android-release-test/gen --generate-dependencies
Applying task javac to nil
Running javac with [-target 1.6 -source 1.6 -Xlint:-options @/var/folders/74/j9q4wrlx40zg637qmnfz4tr40000gn/T/.leiningen-cmdline2418689306678386415.tmp]
Compiling 2 source files to /Users/hash/work/clojure-android-release-test/target/classes
Applying task compile to nil
All namespaces already AOT compiled.
Running javac with [-target 1.6 -source 1.6 -Xlint:-options @/var/folders/74/j9q4wrlx40zg637qmnfz4tr40000gn/T/.leiningen-cmdline2626025842081439150.tmp]
Compiling Clojure files...
Project classpath: (/Users/hash/work/android/sdk//tools/support/annotations.jar /Users/hash/work/android/sdk/platforms/android-15/android.jar /Users/hash/work/clojure-android-release-test/test /Users/hash/work/clojure-android-release-test/src/clojure /Users/hash/work/clojure-android-release-test/src /Users/hash/work/clojure-android-release-test/resources /Users/hash/work/clojure-android-release-test/target/classes /Users/hash/.m2/repository/org/clojure-android/clojure/1.5.1-jb/clojure-1.5.1-jb.jar /Users/hash/.m2/repository/neko/neko/3.0.0/neko-3.0.0.jar)
Build type: release, dynamic compilation: disabled, remote REPL: disabled.
Applying task javac to nil
Running javac with [-target 1.6 -source 1.6 -Xlint:-options @/var/folders/74/j9q4wrlx40zg637qmnfz4tr40000gn/T/.leiningen-cmdline3043222407646477361.tmp]
Compiling com.memerelics.release_test.main
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(com/memerelics/release_test/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-init8686944315769742403.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.
Looking ~/.m2/repository/neko/neko/3.0.0/neko-3.0.0.pom
, it seems point 3.0.0 release commit (https://github.com/alexander-yakushev/neko/commit/8d5341a8fd97d1439f3a3) properly.
...
<scm>
<connection>scm:git:git://github.com/alexander-yakushev/neko.git</connection>
<developerConnection>scm:git:ssh://git@github.com/alexander-yakushev/neko.git</developerConnection>
<tag>8d5341a8fd97d1439f3a337c041f3c10ce6b8525
tag>
<url>https://github.com/alexander-yakushev/neko</url>
</scm>
...
I'm trying to understand lein-droid's compile.clj and neko's init.clj .
Sidenote: you should really pick a much bigger validity term for your release key.
I didn't know expired release key causes such a problem. I must notice it before uploading my app to Google Play. Thanks!
Yes, in the latest release I modified the behaviour of :def
option in defactivity
. It doesn't work in release builds now and for the release you are supposed to manually pass activity object around to use it. Please read these: [1], [2]; and change your code accordingly. Tell me if you have trouble understanding what has to be done.
[1] https://groups.google.com/forum/#!topic/clojure-android/Jl2b_P7Hd7o [2] https://github.com/clojure-android/lein-droid/pull/79#issuecomment-31832315
(defactivity com.memerelics.release_test.MainActivity
:def a
:on-create
(fn [this bundle]
(on-ui
- (set-content-view! a
+ (set-content-view! this
(make-ui [:linear-layout {}
[:text-view {:text "Hello from Clojure!"}]])))))
After I modified my code as above, I could complete release build and it works!
Although creating new project with lein-dorid 0.2.0
and neko 3.0.0
causes an another problem for me, but I can continue current development so it's ok for now. I'll try it with next versions.
Many thanks for your help! I'll close this issue.
Great! One last thing: could you please try creating a new project witn lein-droid 0.2.0 and neko 3.0.0, and add this line to project.clj: :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
, and see if it will work? I suspect this is the problem.
I'm sorry for my late reply. I've tried with latest versions and :javac-options
line in project.clj... Now it works!
Excellent, thank you for the response. I will add this line by default in the next version.
Just for notice:
I get this error because of Kaspersky Antivirus. It suspects the generated classes.dex
Thanks for pointing it out. I don't think there's anything that can be done about it on Leiningen's side, but still good to know.
Hi. First I must thank you for this great project. I'm really enjoying making Android app in Clojure.
Yesterday I faced release build problem. Following procedure is the reproduction of my problem.
First, create project and debug build.
It runs correctly on my device.
Then generate key to sign apk, and edit project.clj to use it.
Finally, I built and run the project as a release version.
The logcat message says my app could not find nrepl server. Release build also require nrepl? Or I've missed some settings?