Maciek
Maciek

Reputation: 171

Xamarin - Java.Lang.RuntimeException just after deploy

I'm working on login page to android application. Right now I've two Activities: Activities in project

If I set MainLauncher = true on MainActivity.cs app deploy with succes. When I set MainLauncher = true to LoginActivity.cs I get:

Java.Lang.RuntimeException: <Timeout exceeded getting exception details> in output console and in messege box:

enter image description here

My LoginActivity.cs code is:

[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));
    }

  }

And layout located in \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>

Upvotes: 1

Views: 2128

Answers (2)

Usman
Usman

Reputation: 2577

I got the same error and there was nothing wrong with my XML files also no issue in my Activity Classes so I resolved this issue by

  1. Cleaning the solution and rebuilding app
  2. If this does not resolve your issue, please delete Debug and Release folders under bin and rebuild solution again.

Hope this will resolve your this issue.

Upvotes: 1

Martin Zikmund
Martin Zikmund

Reputation: 39082

After copy-pasting your provided code into a blank new Android project, everything is working as expected even with MainLauncher = true, excluding the favicon.

Ensure sure you have a favicon.png image inside the drawable folder and its Build Action is set to AndroidResource.

If that doesn't help, I would suggest cleaning the solution and also manually deleting the bin and obj folders in the project folder to make sure there are no conflicting temporary files left behind. Also uninstall the app from your emulator / device completely.

Upvotes: 3

Related Questions