Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android support in version 2 #143

Closed
cruftex opened this issue Aug 14, 2020 · 9 comments · Fixed by #178
Closed

Android support in version 2 #143

cruftex opened this issue Aug 14, 2020 · 9 comments · Fixed by #178
Labels
Milestone

Comments

@cruftex
Copy link
Member

cruftex commented Aug 14, 2020

Version 2 uses Java 8 or later, so it might potentially break Android compatibility.
At the moment we don't have capacity to come up with proper compatibility testing.
While we want to avoid breaking Android compatibility, we cannot guarantee it without proper testing in place.

What would be needed:

  • static verification that only APIs present in Android are used
  • CI jobs that runs test suite
@Betalord
Copy link

Any news on this front? I'd really like to use cache2k on Android, but it seems it's not working.

@cruftex
Copy link
Member Author

cruftex commented Apr 14, 2021

@Betalord: We switched to Java 8 with version 2, however, there weren't any major changes which should break Android compatibility in general. It's just untested. If you find a problem with Android and cache2k version 2.x, please file an issue.

@Betalord
Copy link

@cruftex I'm having problems running it on Android. I add cache2k-api-2.0.0.Final.jar and cache2k-core-2.0.0.Final.jar under Java Build Path -> Libraries, however I get following error:

E/AndroidRuntime(31883): java.lang.NoClassDefFoundError: Failed resolution of: Lorg/cache2k/Cache;
E/AndroidRuntime(15126): Caused by: java.lang.ClassNotFoundException: Didn't find class "org.cache2k.Cache" on path: DexPathList[[zip file "/data/app/com.betalord.sgx-izdkQ73Yn9b5nS5voTUTJA==/base.apk"],nativeLibraryDirectories=[/data/app/com.betalord.sgx-izdkQ73Yn9b5nS5voTUTJA==/lib/arm64, /data/app/com.betalord.sgx-izdkQ73Yn9b5nS5voTUTJA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]

@cruftex
Copy link
Member Author

cruftex commented Apr 14, 2021

@Betalord: More information to reproduce the problem would be helpful (IDE, API level, build tools, etc.). However, it seems that you don't bundle the jars with your application and just have it in the path during compile time.

@Betalord
Copy link

Betalord commented Apr 14, 2021

I'm using Eclipse 4.3 (Kepler), API 28, JRE 8 (with compiler compliance level 1.7), Libgdx 1.9.9. ... not sure what else? Anyway, if I tick the two JARs under "Order and export" (which I do for all JARs I use) and clean all my projects, then I get this error:

Conversion to Dalvik format failed with error 1

Note that Cache works perfectly well on desktop (I have my app divided into 3 projects: android, desktop and core).

EDIT:
Also note that if I add these files (and export them under "Order and export"), then it works perfectly well on android:

  • cache2k-all-1.6.0.Final.jar
  • cache2k-api-1.6.0.Final.jar
  • cache2k-core-1.6.0.Final.jar

@cruftex
Copy link
Member Author

cruftex commented Oct 23, 2021

Played with the Android compiler today to make some progress here:

mvn -DskipTests clean package
mkdir -d target/android
java -jar $ANDROID_HOME/build-tools/28.0.3/lib/d8.jar \
  --lib $ANDROID_HOME/platforms/android-28/android.jar 
  --output target/android \
  cache2k-api/target/*-SNAPSHOT.jar cache2k-core/target/*-SNAPSHOT.jar

The output of d8 is:

Warning in cache2k-core/target/cache2k-core-2.4-SNAPSHOT.jar:org/cache2k/core/log/Log.class:
  Type `org.slf4j.LoggerFactory` was not found, it is required for default or static interface methods desugaring of `org.cache2k.core.log.LogFactory org.cache2k.core.log.Log.initializeLogFactory()`

That looks good. Also did some more research, in case we want to move on to Java 11, that basically
all language features should be supported with newer Android SDKs.

@cruftex
Copy link
Member Author

cruftex commented Nov 6, 2021

For testing the 1.x versions of cache2k I had test projects building a small Android app and also testing the proguard rules. These can be found here:
https://github.com/cache2k/cache2k/tree/service-1.4/test-android
https://github.com/cache2k/cache2k/tree/service-1.4/test-android-proguard

TravisCI and CircleCI have the option to do CI builds for Android apps, GitHub Actions has it as well. I think for the needed setup other Open Source Andrioid apps could be used as an example.

In the long run I want to move all core tests into the cache2k-testsuite. Ideally we package and run this suite on Android as well.

@cruftex
Copy link
Member Author

cruftex commented Dec 7, 2021

@Betalord
I just installed the latest Android studio (2020.3.1) and did a quick test with 2.0.0.Final and 2.5.1.Alpha. Could not find a general problem, meaning, a simple test with building the cache and doing a put and get works.

Minimum API level is 26, since java.time.Duration is needed an probably other stuff.

@cruftex
Copy link
Member Author

cruftex commented Dec 7, 2021

Next steps:
have a CI job that runs the latest commit and its tests in an Android simulator.
I already put some parts of the test suite separately in the cache2k-testsuite module.
Ideally the testing harness should support Junit5 since I plan to move all tests from 4 to 5.

@cruftex cruftex changed the title Android support in version 2 (Needs Help) Android support in version 2 Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants