2017-12-27 225 views
0

我是新來Xamarin並寫了一個簡單的應用程序,但它顯示了以下錯誤Xamarin的ClassNotFoundException

Unhandled Exception: 
Java.Lang.ClassNotFoundException: md5c178831cd46fc53bebc42cf953f78ced.SignupActivity 
occurred 

我對MainActivity代碼:

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

namespace AndroidApp1 
{ 
    [Activity(Label = "Hello Xamarin", MainLauncher = true)] 
    public class MainActivity : Activity 
    { 
     private Button loginButton; 
     private Button signupButton; 
     protected override void OnCreate(Bundle savedInstanceState) 
     { 
      base.OnCreate(savedInstanceState); 
      SetContentView(Resource.Layout.Main); 
      loginButton = (Button)FindViewById(Resource.Id.login_btn); 
      signupButton = (Button)FindViewById(Resource.Id.signup_btn); 
      signupButton.Click += delegate 
      { 
       StartActivity(typeof(SignupActivity)); 
      }; 
     } 
    } 
} 

而對於SignupActivity

using System.Text; 
using Android.App; 
using Android.OS; 
using Android.Widget; 

namespace AndroidApp1 
{ 
    [Activity(Label = "SignupActivity")] 
    public class SignupActivity : Activity 
    { 
     private EditText nameField; 
     private EditText usernameField; 
     private EditText passwordField; 
     private EditText emailField; 
     private Button signup; 
     protected override void OnCreate(Bundle savedInstanceState) 
     { 
      base.OnCreate(savedInstanceState); 
      SetContentView(Resource.Layout.SignupLayout); 
      nameField = (EditText)FindViewById(Resource.Id.name); 
      usernameField = (EditText)FindViewById(Resource.Id.username); 
      emailField = (EditText)FindViewById(Resource.Id.email); 
      passwordField = (EditText)FindViewById(Resource.Id.password); 
      signup = (Button)FindViewById(Resource.Id.signup_btn); 
      signup.Click += delegate 
      { 
       StringBuilder sb = new StringBuilder(); 
       sb.AppendLine(nameField.Text); 
       sb.AppendLine(usernameField.Text); 
       sb.AppendLine(emailField.Text); 
       sb.AppendLine(passwordField.Text); 
       Toast.MakeText(this, sb.ToString(), ToastLength.Short).Show(); 
      }; 
     } 
    } 
} 

你能告訴我我的錯在哪裏?謝謝。

編輯: 清單文件

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
      package="AndroidApp1.AndroidApp1" 
      android:versionCode="1" 
      android:versionName="1.0"> 
    <uses-sdk android:minSdkVersion="21" /> 
    <application android:allowBackup="true" android:label="@string/app_name"> 
    </application> 
</manifest> 
+0

份額清單文件 – Omi

+0

@Omi但我不認爲我必須改變xamarin – Tarptaeya

+0

清單文件https://developer.xamarin.com/releases/android/xamarin.android_8/xamarin.android_8.1/#Known_Issues – SushiHangover

回答

0

這是一個已知的bug,清潔,再建項目,通常可以解決它。

相關問題