Jacob Alley Jacob Alley - 18 days ago 5
Android Question

Android error “unable to find explicit activity class” c#

my activity is called CwiLogInActivity

i declare it in my Splash screen like so:

StartActivity(new Intent(Application.Context, typeof(CwiLogInActivity)));


This is the error message that I get:

Android.Content.ActivityNotFoundException: Unable to find explicit activity class {CwiMyCardApp.CwiMyCardApp/md5de4cbc02688eb358b61123b78d100d94.CwiLogInActivity}; have you declared this activity in your AndroidManifest.xml?


here is my android manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="CwiMyCardApp.CwiMyCardApp" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="19" />
<application android:label="CwiMyCardApp">
<activity android:name=".CwiLogInActivity"/>
</application>
</manifest>


here is my actual CwiLogInActivity.cs ...i am using cheeseknife to resolve my resources and I have no issues with compiling, I am getting my error at runtime.

class CwiLogInActivity : AppCompatActivity
{
static readonly string TAG = "X:" + typeof(CwiLogInActivity).Name;

[InjectView(Resource.Id.loginName)]
EditText loginName;
[InjectView(Resource.Id.passWord)]
EditText passWord;
[InjectView(Resource.Id.loginButton)]
Button loginButton;

[InjectOnClick(Resource.Id.loginButton)]
void OnClickMyButton(object sender, EventArgs e)
{
// This code will run when the button is clicked ...

}

[InjectOnFocusChange(Resource.Id.loginName)]
void OnLoginFocusChange(View v, bool hasFocus)
{
if (hasFocus)
{
loginName.Text = "";
loginName.SetTextColor(Color.Argb(150, 000, 000, 000));
}
}

[InjectOnFocusChange(Resource.Id.loginName)]
void OnPasswordFocusChange(View v, bool hasFocus)
{
if (hasFocus)
{
passWord.Text = "";
loginName.SetTextColor(Color.Argb(150, 000, 000, 000));
}
}

protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Log.Debug(TAG, "SplashActivity.OnCreate");
// Inflate the activity layout resource
SetContentView(Resource.Layout.LoginLayout);

// Use Cheeseknife to inject all attributed view
// fields and events. For an activity injection,
// simply pass in the reference to this activity.
Cheeseknife.Inject(this);
}
}


this seems to be in line with most of the solutions offered to other people who had my problem, yet mine still persists.

Answer

You have no [Activity] attribute defined on this activity. Thus it never gets injected in the AndroidManifest.xml