2

I created a binding for a .jar and it works fine as in a test branch but when moving this same .jar binding to our production branch the following error is thrown.

Java.Lang.ClassNotFoundException: Didn't find class "com.site24x7.android.apm.Apm" on path: DexPathList[[zip file "/data/app/com.mycomany.myappname-1.apk"], nativeLibraryDirectories=[/data/app-lib/com.mycompany.myappname-1, /vendor/lib, /system/lib]]

I found

java.lang.ClassNotFoundException: Didn't find class on path: dexpathlist

but I do not see anywhere in Visual Studio or Xamarin Studio to select Java Build Path and follow those instructions.

Community
  • 1
  • 1
ClintL
  • 1,424
  • 14
  • 30
  • If you take a gander at your `classes.dex` file and search for "Apm", do you find anything? I would suspect not. Thus it's not being put on the main dex list. Try to add a `[Register]` attribute to ensure: https://developer.xamarin.com/api/type/Android.Runtime.RegisterAttribute/ If that doesn't work, ensure you `Embed` your JAR so it's being embedded. – Jon Douglas Aug 24 '16 at 16:55

2 Answers2

2

You need to ensure you Embed your Binding Jar so it'll embed into the .apk. You can find a similar error on our Troubleshooting page:

https://developer.xamarin.com/guides/android/advanced_topics/binding-a-java-library/troubleshooting-bindings/#Problem_NoClassDefFoundError_in_packaging

java.lang.NoClassDefFoundError is thrown in the packaging step.

Possible Causes:

The most likely reason for this error is that a mandatory Java library needs to be added to the application project (.csproj). .JAR files are not automatically resolved. A Java library binding is not always generated against a user assembly that does not exist in the target device or emulator (such as Google Maps maps.jar). This is not the case for Android Library project support, as the library .JAR is embedded in the library dll. For example: https://bugzilla.xamarin.com/show_bug.cgi?id=4288

You can find a small note on Embedded vs Non-Embedded here:

https://gist.github.com/JonDouglas/dda6d8ace7d071b0e8cb#embedded-vs-non-embedded

Jon Douglas
  • 13,006
  • 4
  • 38
  • 51
0

I changed to an EmbeddedJar rather than InputJar and it works fine now. The documentation on Xamarins site did not say it had to be Embedded and the binding project defaulted to Input but InputJar was causing the dexpath issue.

ClintL
  • 1,424
  • 14
  • 30