[英]Xamarin - Java.Lang.RuntimeException just after deploy
我正在登录到Android应用程序页面。 现在我有两个活动:
如果我在MainActivity.cs应用程序部署上设置MainLauncher = true
并取得成功。 当我将MainLauncher = true
设置为LoginActivity.cs时,我得到:
Java.Lang.RuntimeException: <Timeout exceeded getting exception details>
在输出控制台和messege框中:
我的LoginActivity.cs代码是:
[Activity(Label = "Login Page", MainLauncher = true)]
public class LoginActivity : Activity
{
private EditText editTextLogin;
private EditText editTextPassword;
private Button buttonLogin;
public LoginActivity()
{
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Login);
RequestedOrientation = ScreenOrientation.Locked;
editTextLogin = FindViewById<EditText>(Resource.Id.editTextLogin);
editTextPassword = FindViewById<EditText>(Resource.Id.editTextPassword);
buttonLogin = FindViewById<Button>(Resource.Id.buttonLogin);
buttonLogin.Click += OnButtonLoginClick;
}
private void HockeyAppInit()
{
CrashManager.Register(this, HOCKEYAPP_APPID);
UpdateManager.Register(this, HOCKEYAPP_APPID);
}
private void OnButtonLoginClick(object sender, EventArgs eventArgs)
{
// first tests
StartActivity(typeof(MainActivity));
}
}
位于\\ Resources \\ layout中的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:src="@drawable/favicon"
android:layout_width="wrap_content"
android:layout_height="72dp"
android:layout_marginBottom="24dp"
android:layout_gravity="center_horizontal" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="20dp"
android:id="@+id/editTextLogin"
android:singleLine="true" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="20dp"
android:id="@+id/editTextPassword"
android:singleLine="true"
android:password="true" />
<Button
android:id="@+id/buttonLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:text="Zaloguj" />
</LinearLayout>
将您提供的代码复制粘贴到一个空白的新Android项目后,即使MainLauncher = true
,一切都按预期工作,不包括favicon
。
确保drawable
文件夹中有一个favicon.png
图像,其Build Action设置为AndroidResource
。
如果这没有帮助,我建议清理解决方案,并手动删除项目文件夹中的bin
和obj
文件夹,以确保没有留下冲突的临时文件。 还要从您的模拟器/设备中完全卸载该应用程序。
我得到了同样的错误,我的XML文件没有任何问题,我的活动类也没有问题所以我解决了这个问题
希望这能解决您的这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.