-
Notifications
You must be signed in to change notification settings - Fork 564
Description
Hi,
Since Android Studio Gradle Plugin, it's possible to use some Java 11 source code in all Android versions
https://developer.android.com/studio/releases/gradle-plugin#java-11
Is it possible to bind a native android library (.aar), that uses Java 11 source code?
I tried to create a native android library and deployed it in a sample project to Android 5.1.
public class JavaElevenAPI {
public static String stringTest() {
var arrInteger = new Integer[]{5, 9, 3, 6, 2, 4, 8, 7, 1};
long cnt = Arrays.stream(arrInteger).filter(
(@NotNull var a) -> (a != null && a > 5)).count();
System.out.println(cnt);
return Long.toString(cnt);
}
}
Is Android Studio with the native library and the native app, everything worked as expected.
When binding the native library in Xamarin, it builds, but it cashes in runtime with the following error.
java.lang.NoSuchMethodError
No static method stream([Ljava/lang/Object;)Ljava/util/stream/Stream; in class Ljava/util/Arrays; or its super classes (declaration of 'java.util.Arrays' appears in /system/framework/core-libart.jar)
For this to work, it's necessary to use in conjunction with Core Library Dessugaring.
https://developer.android.com/studio/write/java8-support#library-desugaring
Since coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' doesn't exist in Xamarin, I added that library as a dependency.
Is there any way to solve this?
Is this supported in Xamarin?
Thanks