Xamarin.Android Java.Lang.NoClassDefFoundError Failed resolution of: Lokio/Buffer;

Arnold laishram 6 Reputation points
2022-01-17T12:27:11.047+00:00

I am trying create a Xamarin binding library of a native android library which has two dependency.

  1. Google services Vision
  2. Square okhttp3

After adding these 2 packages from Nuget packages, I found out that Google services vision has an internal dependency on

Xamarin.AndroidX.Arch.Core.Runtime and Square okhttp3 library has a dependency on square okio library. My packages list looks like this.

165658-screenshot-2022-01-17-at-51044-pm.png

Once the binding library is build library.dll is generated, I used the library.dll file as a reference in an android app.

After successfully running the app, the internal dependency package, square okio library is not resolved where as the internal dependency package Xamarin.AndroidX.Arch.Core.Runtime has resolved without any issues.

This is the error i am getting

165676-screenshot-2022-01-17-at-51552-pm.png

A workaround i found to make it work is that, in the app if i add a reference of square okio library and run the app, it works.

165711-screenshot-2022-01-17-at-52456-pm.png

Since I am trying to release a library to nuget repository and I wouldn't want the client to add another reference other than my library. Is there a way to make this work without adding any reference in the app? It is okay to add the reference in the binding library but not in the app.

Community Center Not monitored
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.