【问题标题】:Exception trying to use Amazon Device Messaging with Xamarin尝试将 Amazon Device Messaging 与 Xamarin 一起使用时出现异常
【发布时间】:2014-03-29 22:34:44
【问题描述】:

我的应用程序针对 JellyBean,使用 Xamarin Mac 4.2.3 (59)、Android SDK 4.12.0 (Indie),针对 Kindle HDX 设备。要使用 Amazon Device Messaging,我需要能够使用他们在 jar 文件中提供的 SDK。

我有一个 amazon-device-messsaging-1.0.1.jar 的 JAR 绑定项目。

当我尝试调用这行代码时

Com.Amazon.Device.Messaging.ADM adm = new Com.Amazon.Device.Messaging.ADM(this);

我得到一个存根!错误 - 我开始尝试调试的任何想法?或它的含义:) 下面的完整错误。

Java.Lang.RuntimeException:存根!在 Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x00084] 在 /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/98634deb/source/ monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:895 在 Android.Runtime.JNIEnv.FinishCreateInstance (intptr,intptr,intptr,Android.Runtime.JValue[]) [0x0000b] 在 /Users/builder /data/lanes/monodroid-mlion-monodroid-4.12-series/98634deb/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.cs:272 在 Com.Amazon.Device.Messaging.ADM..ctor ( Android.Content.Context) [0x00121] 在 * 在 MyApp.Activity1.OnCreate (Android.OS.Bundle) [0x0005d] 在 * 在 Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr ) [0x00011] 在 /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/98634deb/source/monodroid/src/Mono.Android/platforms/android-17/src/generated/Android.App. Activity.cs:2119 at (wrapper dynamic-method) object.7a557502-bf8c-4d20-89a1-95dfc352585f (intptr,intpt r,intptr) at --- End of managed exception stack trace --- at java.lang.RuntimeException: Stub!在 com.amazon.device.messaging.ADM.(Unknown Source) 在 MyApp.Activity1.n_onCreate(Native Method) 在 MyApp.Activity1.onCreate(Activity1.java:28) 在 android.app.Activity.performCreate (Activity.java:5158) 在 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 在 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2186) 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread .java:2286) 在 android.app.ActivityThread.access$600(ActivityThread.java:149) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1248) 在 android.os.Handler.dispatchMessage( Handler.java:99) 在 android.os.Looper.loop(Looper.java:151) 在 android.app.ActivityThread.main(ActivityThread.java:5185) 在 java.lang.reflect.Method.invokeNative( Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at at com.android.internal .os.Z ygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method)

谢谢!

【问题讨论】:

    标签: android xamarin.android xamarin


    【解决方案1】:

    我刚刚遇到这个,并认为我会发布答案:

    Amazon JAR 包含在设备上实现的对象的“存根”。因此,在构建 APK 时不应“导出”JAR。

    例如,在 Eclipse 中,不要将 amazon jar 放在项目“libs”文件夹中。相反,转到您的项目 Properties -> Java Build Path -> Libraries -> Add External JARs 并以这种方式导入它。然后检查“订购和导出”确保它没有被选中(未导出)。

    当然,如果您的应用程序安装在非 Amazon(非 Fire OS)设备上,您可能需要进行设备检测,这样您就不会调用 Amazon 对象。 (即,您有一个想要在 Amazon 和 Google Play 中分发的应用程序)否则您会收到 ClassNotFound 异常。

    【讨论】:

    • 您将如何在 Visual Studio 中为 xamarin 执行此操作?使用 dll @Jim
    猜你喜欢
    • 1970-01-01
    • 2013-08-29
    • 1970-01-01
    • 2016-05-21
    • 1970-01-01
    • 1970-01-01
    • 2020-03-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多