Redth / Xamarin.Binding.Helpers

MSBuild Tasks to help with Binding projects for Xamarin Android and iOS
MIT License
41 stars 7 forks source link

Java.Lang.NoClassDefFoundError #4

Open corne-du-plooy opened 1 year ago

corne-du-plooy commented 1 year ago

Hi Jonathan,

I am trying the slim bindings approach for Forms (5.0.0.2515) and have added the Xamarin.Binding.Helpers Nuget to both my Android Binding Library and to the .Android project as per the instructions. (VS for Mac - Tried 2019 and 2022)

I am using the latest version of the Mapbox library (10.8.0).

When I run the app it launches fine, but when my Custom Renderer tries to call the init of the Binding library I get the below exception:

{Java.Lang.NoClassDefFoundError: Failed resolution of: Lcom/mapbox/maps/MapView; ---> Java.Lang.ClassNotFoundException: Didn't find class "com.mapbox.maps.MapView" on path: DexPathList[[zip file "/data/app/com.test.mapboxtest-ggWWGq9F42iegDtVSeLtXA==/b…}

The error is thrown from the following line in the generated API Definition file:

_members.InstanceMethods.FinishCreateInstance (id, this, `args);`

The full method that is generated:

// Metadata.xml XPath constructor reference: path="/api/package[@name='com.test.mapboxwrapper']/class[@name='MapboxWrapper']/constructor[@name='MapboxWrapper' and count(parameter)=2 and parameter[1][@type='android.app.Activity'] and parameter[2][@type='com.test.mapboxwrapper.MapboxWrapperCallback']]"
        [Register (".ctor", "(Landroid/app/Activity;Lcom/test/mapboxwrapper/MapboxWrapperCallback;)V", "")]
        public unsafe MapboxWrapper (global::Android.App.Activity activity, global::Com.test.Mapboxwrapper.IMapboxWrapperCallback @callback) : base (IntPtr.Zero, JniHandleOwnership.DoNotTransfer)
        {
            const string __id = "(Landroid/app/Activity;Lcom/test/mapboxwrapper/MapboxWrapperCallback;)V";

            if (((global::Java.Lang.Object) this).Handle != IntPtr.Zero)
                return;

            try {
                JniArgumentValue* __args = stackalloc JniArgumentValue [2];
                __args [0] = new JniArgumentValue ((activity == null) ? IntPtr.Zero : ((global::Java.Lang.Object) activity).Handle);
                __args [1] = new JniArgumentValue ((@callback == null) ? IntPtr.Zero : ((global::Java.Lang.Object) @callback).Handle);
                var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args);
                SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);
                _members.InstanceMethods.FinishCreateInstance (__id, this, __args);
            } finally {
                global::System.GC.KeepAlive (activity);
                global::System.GC.KeepAlive (@callback);
            }
        }

I can see the "package.targets" file is generated in "obj/debug/xbh" and all the aar's are copied to the "artefacts" subdirectory

any pointers on how to resolve this would be greatly appreciated!