我剛剛安裝了新的Visual Studio for Mac,但無法在模擬器上運行標準應用程序。這是當您創建新項目時由Visual Studio創建的「hello world」應用程序。我試圖使用附帶的模擬器運行它,但也Xamarin Android播放器。但是,對於這兩個仿真器,我收到以下錯誤:運行標準Xamarin應用程序時遇到問題
「不幸的是,應用程序已停止。」
模擬器正常工作。這只是給應用帶來問題的應用。
我覺得我錯過了某些東西在清單或東西。但這是標準的應用程序。它應該工作,對吧?
代碼從主要活動:
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.MonoRuntimePro vider: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) 在android.app.ActivityThread [AndroidRuntime] $ H.handleMessage(ActivityThread.java:1405) [AndroidRuntime] android.os.Handler.dispatchMessage(Handler.java:102) [AndroidRuntime] at android.os.Looper.loop(Looper.java:148) [androidruntime] at android.app.ActivityThread.main(ActivityThread.java :5417) [AndroidRuntime] at java.lang.reflect.Method.invoke(Nati ve方法) [AndroidRuntime] at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726) [AndroidRuntime] at 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] at android.app.ApplicationPackageManager.getApplicationInfo(ApplicationPackageManager.java:304) [AndroidRuntime]在mono.MonoRuntimeProvider.attachInfo(MonoRuntimeProvider.java :32) [AndroidRuntime] ...更多
當然,沒有生成錯誤。 – Zarif
當您說「不幸的是,應用程序已停止」時,您應該會看到一些錯誤。 –
必須有一些運行時錯誤。模擬器的API級別是什麼? – Andrius