Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android error “unable to find explicit activity class”

Tags:

android

I've been at this for hours and can't figure it out. When I debug, it gives the above error. I'm new to this so go gentle if it's something obvious that I"m missing...

here's the code which introduced the crash from the first activity, it's still labeled 'Main':

//-- Menu Press --

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

//-- Handle item selection
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_settings:
            Intent menu = new Intent(this, Menu.class);
            menu.putExtra("plWin", plWin);
            menu.putExtra("plLoss", plLoss);
            menu.putExtra("plDraw", plDraw);
            startActivity(menu);
            return true;
        case R.id.menu_reset:
            if (opCounter > plCounter) {
                plLoss++;
            }else if (opCounter < plCounter) {
                plWin++;
            }else {
                plDraw++;
            }
            opCounter = 0;
            plCounter = 0;
            return true;
        default:
            return false;
    }

}

and the second activity, currently named 'Menu':

public class Menu extends Activity {

Intent menu = getIntent();
int wins = menu.getIntExtra("plWin", 0);
int losses = menu.getIntExtra("plLoss", 0);
int draws = menu.getIntExtra("plDraw", 0);

private TextView winNum = null;
private TextView lossNum = null;
private TextView drawNum = null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menu);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


    //-- Win Counter --
    LinearLayout winView = (LinearLayout) findViewById(R.id.plLeft);
    winNum = (TextView) winView.findViewById(R.id.winNum);
    winNum.setText("" + wins);

    //-- loss Counter --
    LinearLayout lossView = (LinearLayout) findViewById(R.id.plMid);
    lossNum = (TextView) lossView.findViewById(R.id.lossNum);
    lossNum.setText("" + losses);

    //-- Draw Counter --
    LinearLayout drawView = (LinearLayout) findViewById(R.id.plRight);
    drawNum = (TextView) drawView.findViewById(R.id.drawNum);
    drawNum.setText("" + draws);
}

public void onBackPressed() {
    finish();
    super.onBackPressed();
}

}

and here's my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sesto.life.counter"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".Main"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity 
        android:name="com.sesto.life.counter.Menu"
        android:label="@string/title_activity_menu" >

    </activity>  

</application>

I'm looking for ideas. Thank you all in advance

like image 363
Psest328 Avatar asked Sep 01 '12 02:09

Psest328


2 Answers

I only see one possible mistake is at Intent menu = new Intent(this, Menu.class); . Please check Menu.class is your Menu class but not Android Menu View (located at android.view.Menu). The logcat told that it can not find android.view.Menu in manifest. Hover your mouse pointer above Menu.class to check which class you imported for this.

like image 108
Trung Nguyen Avatar answered Oct 21 '22 04:10

Trung Nguyen


Change

<activity 
        android:name="com.sesto.life.counter.Menu"
        android:label="@string/title_activity_menu" >

</activity>  

to

<activity 
    android:name=".Menu"
    android:label="@string/title_activity_menu" >

</activity>  

and see if that helps

like image 41
Infinity Avatar answered Oct 21 '22 06:10

Infinity