clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
645 stars 56 forks source link

Serious JDK versioning issues. #161

Open collinalexbell opened 7 years ago

collinalexbell commented 7 years ago

I am running 16.06 Ubuntu on a MacBook Air with both openjdk-7 and openjdk-8 installed. I have installed Android Studio 2.3.1

Android Studio post SDK 24 ships with the 1.8 JRE. This means that it compiles the SDK using JDK 1.8

I am getting problems running lein droid.

If I use openjdk-7 as my java I produce this error while compiling code.


Compiling neko.log
Exception in thread "main" java.lang.UnsupportedClassVersionError: android/util/Log : Unsupported major.minor version 52.0, compiling:(/tmp/form-init6532476813401129275.clj:1:73)

android/util/Log was compiled with jdk8

If I use openjdk-8 as my java it produce this error after compiling all the clojure.

Creating DEX....

PARSE ERROR:
unsupported class file version 52.0
...while parsing android/annotation/SuppressLint.class
1 error; aborting

By "use x as my java" I mean I run sudo update-alternatives --config java which allows me to change the output of java -version

AetherQuinque commented 7 years ago

On Macbook pro 2015 (10.12.4) with java version "1.7.0_80" I'm getting same problem.

collinalexbell commented 7 years ago

@AetherQuinque The way I got it to work was upgrade Java to version 1.8, then I changed javac-options to use 1.7 for both source and target in my project.clj

:javac-options ["-target" "1.7" "-source" "1.7" "-Xlint:-options"]

Finally, I had to manually download and replace a dependency annotations.jar in /path/to/sdk/tools/support/which can be found here: https://mvnrepository.com/artifact/com.google.android/annotations/4.1.1.4

I am currently searching for a way to take this project into using Java8 and Clojure 1.9, but I think I might need help from @alexander-yakushev to get an idea of what would need to be done. Lein-droid uses its own modified branch of clojure.core it seems.

interstar commented 7 years ago

Thanks @SlightlyCyborg I hit this problem today.

And your solution above (including updating the annotations.jar) solved it.

I also found this http://java.wekeepcoding.com/article/10014189/Android%27s+SDKs+are+compiled+in+Java8+since+Android+studio+2.3%2C+but+I+can%27t+use+dk+build+tool+with+Java8. which might help someone