运行标准Xamarin应用程序遇到麻烦

时间:2016-11-19 15:16:03

标签: c# android xamarin xamarin.android visual-studio-mac

我刚安装了新的Visual Studio for Mac,但我无法在模拟器上运行标准应用程序。这是"你好世界"您在创建新项目时由Visual Studio自己创建的应用程序。我尝试使用附带的模拟器以及Xamarin Android Player运行它。但是,对于这两个模拟器,我收到以下错误:

"不幸的是,应用程序停止了。"

模拟器工作正常。它只是提供问题的应用程序。

我觉得我错过了清单中的某些东西。但这是标准的应用程序。它应该工作,对吗?

主要活动的代码:

using Android.App;
using Android.Widget;
using Android.OS;

namespace Project_App3.Droid
{
    [Activity(Label = "App3", MainLauncher = true, Icon =     "@mipmap/icon")]
public class MainActivity : Activity
{
    int count = 1;

    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);

        // Get our button from the layout resource,
        // and attach an event to it
        Button button = FindViewById<Button>(Resource.Id.myButton);

        button.Click += delegate { button.Text = $"{count++} clicks!"; };
    }
}
}

清单代码:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"     android:versionCode="1" android:versionName="1.0"     package="com.test.app3">
<uses-sdk android:minSdkVersion="15" />
<application android:label="App3">
</application>
</manifest>

申请表输出:

[art] Not late-enabling -Xcheck:jni (already on)
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main

[AndroidRuntime]进程:com.test.app3,PID:5225 [AndroidRuntime] java.lang.RuntimeException:无法获取提供者mono.MonoRuntimeProvider:java.lang.RuntimeException:无法找到应用程序Mono.Android.Platform.ApiLevel_24或Xamarin.Android.Platform! [AndroidRuntime]在android.app.ActivityThread.installProvider(ActivityThread.java:5156) [AndroidRuntime]在android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) [AndroidRuntime]在android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) [AndroidRuntime]在android.app.ActivityThread.-wrap1(ActivityThread.java) [AndroidRuntime]在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1405) [AndroidRuntime]在android.os.Handler.dispatchMessage(Handler.java:102) [AndroidRuntime]在android.os.Looper.loop(Looper.java:148) [AndroidRuntime]在android.app.ActivityThread.main(ActivityThread.java:5417) [AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method) [AndroidRuntime]在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726) [AndroidRuntime]在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) [AndroidRuntime]引起:java.lang.RuntimeException:无法找到应用程序Mono.Android.Platform.ApiLevel_24或Xamarin.Android.Platform! [AndroidRuntime]在mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:38) [AndroidRuntime]在android.app.ActivityThread.installProvider(ActivityThread.java:5153) [AndroidRuntime] ......还有10个 [AndroidRuntime]引起:android.content.pm.PackageManager $ NameNotFoundException:Xamarin.Android.Platform [AndroidRuntime]在android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:304) [AndroidRuntime]在mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java:32) [AndroidRuntime] ... 11更多

1 个答案:

答案 0 :(得分:1)

我找到了使用Andrius&#39;救命。我搜索了运行时异常,我在这里找到了解决方案:unable to create helloworld

我将目标框架更改为Android Marshmallow