I’m trying to access a 3rd party Android SDK from my Ionic app.
The 3rd party Android SDK imports “java8.util.concurrent.CompletableFuture”, and I was able to get it to work from Android Studio using a test native app.
To make sure I understand: I’m already building a Cordova plugin to wrap the 3rd party Android SDK (and this SDK references the java8 class file that is appearing the build error). Are you saying that I should try to include the “java8.util.concurrent.CompletableFuture” class file into the existing plugin somehow?
Also: When exactly do you get this error? What command do you execute to get this error? What is your ionic info and other environment information for this?
Thanks for the link! I’ll have to see if I can get Java8 to be recognized by Cordova today. If not, I will have to take a different (non-preferred) approach without a Cordova plugin.
I got the Java8 error with the command “ionic cordova build android” after adding my plugin.
My computer has Java 1.8 and I’m using the latest version of ionic etc. Note that the same SDK that uses Java8 works fine from Android Studio.
java -version
openjdk version "1.8.0_112-release"
OpenJDK Runtime Environment (build 1.8.0_112-release-b06)
OpenJDK 64-Bit Server VM (build 25.112-b06, mixed mode)
Ok, I think I’m giving up on trying to get Java8 to work with a Cordova plugin for today. Found too many versioning issues, which I will summarize below.
I tried creating “cordova-plugin-java8” based on https://github.com/cvuser0/cordova-plugin-java7, and then adding in my other plugin that references Java8 code (e.g. the “java8.util.concurrent.CompletableFuture” class). I got an application build error Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8. When I enabled Jack, I got another application build error com.android.jack.api.v01.CompilationException: Failed to compile. All these issues might be because the Jack toolchain is deprecated as per https://developer.android.com/studio/preview/features/java8-support.html#disable_jack.
I looked at the build.gradle file for my native test app created with Android Studio, and it was clean and works with the Java8 features. The generated build.gradle file for the Cordova/Ionic Android app still references JavaVersion.VERSION_1_6, and trying to change it to JavaVersion.VERSION_1_8 with “cordova-plugin-java8” and other attempts led to the errors previously mentioned.