question

BergQuester avatar image
BergQuester asked

Crash when running with Xamarin Kindle IAP

Following the steps at https://developer.amazon.com/public/solutions/platforms/cross-platform/xamarin/docs/adding-a-plugin-to-your-xamarin-project

Getting this crash. What gives?

System.NotSupportedException: Could not activate JNI Handle 0x7fff3b91368c (key_handle 0x1cc5b91b) of Java type 'md58441721984586c4571cb9a14cde11b83/MainActivity' as managed type 'MyApp.Droid.MainActivity'. ---> System.TypeInitializationException: The type initializer for 'Builder' threw an exception. ---> Java.Lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.client.myApp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.client.myApp-1/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find "libAmazonIapV2Bridge.so"
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <183b200ee49746d48fc781625979428e>:0
  at Java.Interop.JniEnvironment+StaticMethods.CallStaticVoidMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <50812bf827614c0faffacac58772b4fa>:0
  at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeVoidMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in <50812bf827614c0faffacac58772b4fa>:0
  at Java.Lang.JavaSystem.LoadLibrary (System.String libname) [0x00029] in <71828dd8fb5f4508815e23d6996c45c2>:0
  at com.amazon.device.iap.cpt.AmazonIapV2Impl+AmazonIapV2Android.get_Instance () [0x00016] in <909e8c2781f24da69e9ca12b0195ac21>:0
  at com.amazon.device.iap.cpt.AmazonIapV2Impl+Builder..cctor () [0x00000] in <909e8c2781f24da69e9ca12b0195ac21>:0
  at java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.client.myApp-1/base.apk"],nativeLibraryDirectories=[/data/app/org.client.myApp-1/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find "libAmazonIapV2Bridge.so
  at at java.lang.Runtime.loadLibrary(Runtime.java:366)
  at at java.lang.System.loadLibrary(System.java:988)
  at at mono.android.TypeManager.n_activate(Native Method)
  at at mono.android.TypeManager.Activate(TypeManager.java:7)
  at at md58441721984586c4571cb9a14cde11b83.MainActivity.<init>(MainActivity.java:26)
  at at java.lang.reflect.Constructor.newInstance(Native Method)
  at at java.lang.Class.newInstance(Class.java:1606)
  at at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
  at at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
  at at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
  at at android.app.ActivityThread.access$800(ActivityThread.java:151)
  at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
  at at android.os.Handler.dispatchMessage(Handler.java:102)
  at at android.os.Looper.loop(Looper.java:135)
  at at android.app.ActivityThread.main(ActivityThread.java:5254)
  at at java.lang.reflect.Method.invoke(Native Method)
  at at java.lang.reflect.Method.invoke(Method.java:372)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  --- End of inner exception stack trace ---
  at at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr)
  at com.amazon.device.iap.cpt.AmazonIapV2Impl.get_Instance () [0x00001] in <909e8c2781f24da69e9ca12b0195ac21>:0
  at MyApp.Droid.AmazonIAPController..ctor () [0x00008] in /Volumes/HomeSSD/danielbergquist/src/app/MyApp/Droid/AmazonIAPController.cs:16
  at MyApp.Droid.MainActivity..ctor () [0x0000c] in /Volumes/HomeSSD/danielbergquist/src/app/MyApp/Droid/MainActivity.cs:20
  at at (wrapper dynamic-method) System.Object:891d7f60-510b-4b30-9cef-1fa96e87a12f (intptr,object[])
  at Java.Interop.TypeManager.n_Activate (System.IntPtr jnienv, System.IntPtr jclass, System.IntPtr typename_ptr, System.IntPtr signature_ptr, System.IntPtr jobject, System.IntPtr parameters_ptr) [0x000de] in <71828dd8fb5f4508815e23d6996c45c2>:0
  --- End of inner exception stack trace ---


iapandroid
10 |3000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Levon@Amazon avatar image
Levon@Amazon answered

Hi BergQuester,

Thanks for posting! The Xamarin plugin hasn't been modified for some time, so this exception is not because of some changes to it. What Android SDK version are you building this against? If fairly old, can you update to the latest? Do you have the latest support libraries? Are you accessing any properties in a method where those values have not been set yet (for example, trying to read Height or Width in the constructor, instead of OnDraw(), etc). Are you calling a method on an object that's null? Can you set breakpoints and try to debug your project step by step? Specifically put breakpoints on your class constructors and go from there. If you are sure none of those apply, have you tried to clean your project, or start a new one from scratch?

For reference, see also this SO thread: https://stackoverflow.com/questions/10593022/monodroid-error-when-calling-constructor-of-custom-view-twodscrollview

10 |3000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.