dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 528 forks source link

Missing support of Rx Kotlin package #2246

Closed Miiite closed 6 years ago

Miiite commented 6 years ago

I am working on a custom android binding project, for a pretty massive AR sdk (https://bear2b.com/)

I've struggled with the great number of references the Android project has, but found a way to fix most of them. Right now, I'm stuck on an exception that seems to be like it's related to the Kotlin support for Xamarin.Android binding projects.

I'd like to know (at least) if my binding project is actually doable on Android, because the iOS counterpart is working.

Steps to Reproduce

  1. Build and run the Demo.Bear2b.Android project attached
  2. When creating a new instance of the BearHandler class, a runtime exception is raised [MonoDroid] UNHANDLED EXCEPTION: [MonoDroid] Java.Lang.NoClassDefFoundError: Failed resolution of: Lrx/lang/kotlin/SubjectsKt; ---> Java.Lang.ClassNotFoundException: Didn't find class "rx.lang.kotlin.SubjectsKt" on path: DexPathList[[zip file "/data/app/com.ikomobi.Demo_Bear2b_Android-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ikomobi.Demo_Bear2b_Android-1/lib/arm, /data/app/com.ikomobi.Demo_Bear2b_Android-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] [MonoDroid] --- End of inner exception stack trace --- [MonoDroid] at Java.Interop.JniEnvironment+Object.AllocObject (Java.Interop.JniObjectReference type) [0x0003c] in :0 [MonoDroid] at Java.Interop.JniType.AllocObject () [0x0000c] in :0 [MonoDroid] at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x0003e] in :0 [MonoDroid] at Com.Bear.Common.Sdk.BearHandler..ctor () [0x00026] in /Users/Adrien/Git/bearsdkbinding/BearSdk.Binding.Android/obj/Debug/generated/src/Com.Bear.Common.Sdk.BearHandler.cs:313 [MonoDroid] at Demo.Bear2b.Android.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00015] in /Users/Adrien/Git/bearsdkbinding/Demo.Bear2b.Android/MainActivity.cs:19 [MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_osBundle (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in :0 [MonoDroid] at (wrapper dynamic-method) System.Object.3(intptr,intptr,intptr) [MonoDroid] --- End of managed Java.Lang.NoClassDefFoundError stack trace --- [MonoDroid] java.lang.NoClassDefFoundError: Failed resolution of: Lrx/lang/kotlin/SubjectsKt; [MonoDroid] at com.bear.common.sdk.BearHandler.(BearHandler.kt:191) [MonoDroid] at md593aaffe1cd3ad727d690009dc61a5fe5.MainActivity.n_onCreate(Native Method) [MonoDroid] at md593aaffe1cd3ad727d690009dc61a5fe5.MainActivity.onCreate(MainActivity.java:29) [MonoDroid] at android.app.Activity.performCreate(Activity.java:6251) [MonoDroid] at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) [MonoDroid] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) [MonoDroid] at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) [MonoDroid] at android.app.ActivityThread.-wrap11(ActivityThread.java) [MonoDroid] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) [MonoDroid] at android.os.Handler.dispatchMessage(Handler.java:102) [MonoDroid] at android.os.Looper.loop(Looper.java:148) [MonoDroid] at android.app.ActivityThread.main(ActivityThread.java:5417) [MonoDroid] at java.lang.reflect.Method.invoke(Native Method) [MonoDroid] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) [MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) [MonoDroid] Caused by: java.lang.ClassNotFoundException: Didn't find class "rx.lang.kotlin.SubjectsKt" on path: DexPathList[[zip file "/data/app/com.ikomobi.Demo_Bear2b_Android-1/base.apk"],nativeLibraryDirectories=[/data/app/com.ikomobi.Demo_Bear2b_Android-1/lib/arm, /data/app/com.ikomobi.Demo_Bear2b_Android-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]] [MonoDroid] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) [MonoDroid] at java.lang.ClassLoader.loadClass(ClassLoader.java:511) [MonoDroid] at java.lang.ClassLoader.loadClass(ClassLoader.java:469) [MonoDroid] ... 15 more [MonoDroid] Suppressed: java.lang.ClassNotFoundException: rx.lang.kotlin.SubjectsKt [MonoDroid] at java.lang.Class.classForName(Native Method) [MonoDroid] at java.lang.BootClassLoader.findClass(ClassLoader.java:781) [MonoDroid] at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) [MonoDroid] at java.lang.ClassLoader.loadClass(ClassLoader.java:504) [MonoDroid] ... 16 more

I am in touch with the android developer that created this SDK. His response to me was that the class name I sent (i.e rx/lang/kotlin/SubjectsKt) is part of Kotlin and is not an external library like I thought.

REPRO project:

https://drive.google.com/file/d/1X8Cmzfg1HwRNeOPYzOA0c2M-Qkk8vO7f/view?usp=sharing

Expected Behavior

The package containing the expected class looks like it is part of standard Kotlin. A "rx.kotlin" package should be available to xamarin dev to enable supporting this package in a binding project ?!

Actual Behavior

The app crashes because some part of Kotlin support is not available to us ?

Version Information

=== Visual Studio Professional 2017 for Mac ===

Version 7.6.7 (build 49) Installation UUID: d5fab6e8-f72f-4667-a53b-3916e30e44a3 Runtime: Mono 5.12.0.301 (2018-02/4fe3280bba1) (64-bit) GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

Package version: 512000301

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 2.1.2 2.1.1 2.0.5 2.0.3 1.1.1 1.1.0 1.0.4 SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks SDK Versions: 2.1.302 2.1.301 2.1.4 2.0.3 1.0.3 1.0.0-preview2-1-003177 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.3 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 9.0.0.20 (Visual Studio Professional) Android SDK: /Users/Adrien/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 4.0.3 (API level 15) 4.4 (API level 19) 5.0 (API level 21) 6.0 (API level 23) 7.0 (API level 24) 7.1 (API level 25) 8.0 (API level 26) 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 28.0.0 SDK Build Tools Version: 28.0.2

Java SDK: /usr java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 10.0 (14320.25) Build 10A255

=== Xamarin.Mac ===

Version: 4.6.0.14 (Visual Studio Professional) Hash: 1a6e2786 Branch: Build date: 2018-08-28 00:12:06-0400

=== Xamarin.iOS ===

Version: 12.0.0.15 (Visual Studio Professional) Hash: 84552a46 Branch: xcode10 Build date: 2018-09-17 21:54:33-0400

=== Xamarin Inspector ===

Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09 Jul 2018 21:20:18 GMT Client compatibility: 1

=== Build Information ===

Release ID: 706070049 Git revision: 0b48ccfb376397678b3bc3653da2c6603d35357d Build date: 2018-09-20 21:14:23+00 Build branch: release-7.6 Xamarin extensions: b25fd1e2b9a7859aff9536924e8edb6cbfb78637

=== Operating System ===

Mac OS X 10.13.6 Darwin 17.7.0 Darwin Kernel Version 17.7.0 Thu Jun 21 22:53:14 PDT 2018 root:xnu-4570.71.2~1/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

MFractor 3.5.22 MSBuild Editor 2.0.4 Template Creator 0.4 Redth's Addins 1.0.9

grendello commented 6 years ago

Hi @Miiite, I've checked and there's no class named SubjectsKt anywhere in the Kotlin sources (checked the 1.2.71 release):

$ rgrep -H SubjectsKit * || echo no matches
no matches

However, even if it was present in the Kotlin distribution please note that Xamarin.Android does not distribute any parts of the the Android SDK, NDK parts and the same applies to Kotlin. Those projects are external to and independent of Xamarin.Android and if any binding uses libraries part of those (or any other) projects, the binding must provide and take care of all its dependencies. I hope you will find a way to resolve the missing dependency :)

Miiite commented 6 years ago

Hi @grendello Before creating this bug I contacted the android developer in charge of this SDK, and he told be that this class is part of the Kotlin language and is not custom nor a library ... I'll check again with him. Thanks for your time :)