Xamarin Android 应用程序意外关闭

Xamarin Android application closed unexpectedly

我尝试使用 xamarin studio 创建 android 应用程序。我安装 xamarin studio 并创建一个新的 android 应用程序。应用程序在模拟器上成功 运行。但是在我的 android phone 中安装 apk 后,当打开应用程序时我收到消息 "Unfortunately Application has stopped" 。项目目标版本是 4.03。模拟器 android 版本是 4.03,我的 phone os 版本也是 4.03。什么是实际问题。我是 xamarin studio 的 buginner。有什么想法吗??

这是设备日志

09-01 19:12:46.654: E/AndroidRuntime(22866): FATAL EXCEPTION: main
09-01 19:12:46.654: E/AndroidRuntime(22866):  Process:com.gadgeon.helloworld, PID: 22866
09-01 19:12:46.654: E/AndroidRuntime(22866):   java.lang.RuntimeException:  Unable to get provider   mono.MonoRuntimeProvider: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_15 or Xamarin.Android.Platform!
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.app.ActivityThread.installProvider(ActivityThread.java:5002)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.app.ActivityThread.access00(ActivityThread.java:151)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.os.Handler.dispatchMessage(Handler.java:102)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.os.Looper.loop(Looper.java:135)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.app.ActivityThread.main(ActivityThread.java:5254)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at java.lang.reflect.Method.invoke(Native Method)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at java.lang.reflect.Method.invoke(Method.java:372)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
09-01 19:12:46.654: E/AndroidRuntime(22866): Caused by: java.lang.RuntimeException: Unable to find application Mono.Android.Platform.ApiLevel_15 or Xamarin.Android.Platform!
09-01 19:12:46.654: E/AndroidRuntime(22866):  at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:38)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.app.ActivityThread.installProvider(ActivityThread.java:4999)
09-01 19:12:46.654: E/AndroidRuntime(22866):  ... 11 more
09-01 19:12:46.654: E/AndroidRuntime(22866): Caused by: android.content.pm.PackageManager$NameNotFoundException: Xamarin.Android.Platform
09-01 19:12:46.654: E/AndroidRuntime(22866):  at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:281)
09-01 19:12:46.654: E/AndroidRuntime(22866):  at mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:32)

编辑您的 .csproj,

变化:

<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>

收件人:

<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>

然后清理、重建并重新安装 apk

问题已解决。

无法获取在调试模式下创建的 .apk 文件。

  1. 使用发布模式构建项目。
  2. select 构建 > 发布存档

这将生成最终的 apk 文件。我们可以毫无问题地安装和使用这个apk文件。

在此处了解更多信息:http://docs.xamarin.com/guides/android/getting_started/installation/set_up_device_for_development