是什么导致应用程序在我的三星s9 +上崩溃,它在Visual Studio中的android模拟器中可以正常工作。
这是我的控件布局
[它在Visual Studio android模拟器中完美工作,但是当我在三星s9 +上安装apk时,它崩溃了。
我的设置:Android 10配置:发布
有人可以解释导致问题的原因吗?
[当我在三星s9 +上打开应用程序时,它立即崩溃,我也重置了设备,但仍然崩溃。它可以在Visual Studio Android模拟器上完美运行]
这是我的控件布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation = "vertical">
<Button
android:text="Execute"
android:layout_width="386.5dp"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/ExecuteButton" />
<TextView
android:text="Type your command below:"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ExecuteButton"
android:id="@+id/textView1" />
<EditText
android:layout_width="382.5dp"
android:layout_height="56.5dp"
android:layout_below="@id/CommandText"
android:id="@+id/CommandText" />
<TextView
android:text="Other Tools"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ShutdownButton"
android:id="@+id/textView2" />
<Button
android:text="Shutdown Computer"
android:layout_width="386.5dp"
android:layout_height="wrap_content"
android:layout_below="@id/CommandText"
android:id="@+id/ShutdownButton"
android:layout_toRightOf="@id/textView2"
android:layout_marginBottom="0.0dp"
android:layout_marginTop="0.0dp"
android:layout_marginRight="1.5dp"
android:layout_marginLeft="0.5dp" />
</LinearLayout>```
Here is my mainactivity.cs
using System;
using System.IO;
using System.Net;
using System.Net.Mime;
using System.Reflection.Emit;
using System.Threading;
using Android.App;
using Android.OS;
using Android.Support.V7.App;
using Android.Runtime;
using Android.Widget;
namespace Command_Execute_Controller
{
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
public class MainActivity : AppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
Button ExecuteButton = FindViewById<Button>(Resource.Id.ExecuteButton);
EditText Command = FindViewById<EditText>(Resource.Id.CommandText);
Button ShutdownComputer = FindViewById<Button>(Resource.Id.ShutdownButton);
ExecuteButton.Click += (sender, args) =>
{
using (var client = new WebClient())
{
client.Credentials = new NetworkCredential("epiz_25603682", "SXcuEhK9CBSi2Y");
client.UploadStringAsync(new Uri("ftp://ftpupload.net/htdocs/Status%20Folder/Status.txt"), "command" + "\n" + Command.Text);
while (client.IsBusy)
{
Thread.Sleep(10);
}
}
};
ShutdownComputer.Click += (sender, args) =>
{
using (var client = new WebClient())
{
client.Credentials = new NetworkCredential("epiz_25603682", "SXcuEhK9CBSi2Y");
client.UploadStringAsync(new Uri("ftp://ftpupload.net/htdocs/Status%20Folder/Status.txt"), "shutdown");
while (client.IsBusy)
{
Thread.Sleep(10);
}
}
};
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}