Best practises for Android (trying to compile for 7, getting class file version errors)

48 views
Skip to first unread message

ciphe...@gmail.com

unread,
Apr 25, 2021, 4:35:26 PM4/25/21
to H2 Database
Hello,

I've been using H2 version 1.4 (which I compiled with Java 6) for such a long time that I've almost forgotten the last time I went through this hassle.

It looks like the current development version of H2 (2.0.201) requires at least Java 8.

If I compile the .jar with OpenJDK 8 and try to integrate it into and Android app targeted for Android SDK 26, class file conversion fails however - complaining about versions.

What would you do in this situation?

- would you target your app at some newer version of Android? (I cannot go past 9, specific hardware is involved.)

- would you try to backport the codebase of H2 to Java 7 and compile it somehow? (I have done a similar thing a long time ago and it wasn't fun)

- what flavour of Java have developers traditionally used to compile releases? Because somehow, a release binary from 2019 (I assume it's 1.4.200 or something) works on the required Android device...

I'd be grateful for any ideas or suggestions. :)

Jaan

Evgenij Ryazanov

unread,
Apr 25, 2021, 11:56:48 PM4/25/21
to H2 Database
Hello.

Android is far behind regular Java, some its parts, especially the JDBC API are still somewhere on Java 6 level, so you cannot use current H2 on this platform, it is not supported by H2 any more.

Android API 26 got various significant improvements for better compatibility with Java 7 and 8, but not in the JDBC area. Current H2 requires at least JDBC 4.2. It was released 7 years ago with Java 8, but Android still doesn't support it and has many other limitations. Java 8 by itself is not a problem if you don't support very old devices, but various missing Java APIs used by non-Android libraries, including the H2, is the real problem of this platform.

The simplest solution there is to use some old release of H2 that works for you.

ciphe...@gmail.com

unread,
Apr 26, 2021, 11:06:47 AM4/26/21
to H2 Database
Thank you for your quick reply and advise. Indeed, different versions of JDBC make any sort of backporting feel like an overwhelming task in the short term.

Regarding the old version of H2 that has worked for me so far - the problem is that I'm trying to migrate off it due to a bug which I've been unable to fix.

I think that for the time being, I will put renewed effort into fixing the old bug. If I get it fixed, I have no pressure to migrate to 2.0 and can wait for Android to reach somewhere with its development.
Reply all
Reply to author
Forward
0 new messages