-1

This is the android manifest:

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/pic"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.thenewboaton.travis.abc"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

         <activity
            android:name="com.thenewboaton.traivs.splash"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.thenewboaton.Splash" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

</manifest>

The Main java class named MainActivity:

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;




    public class MainActivity extends Activity {

        int counter;
        Button add;
        Button sub;
        TextView display;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.splash);
            counter=0;
            add=(Button)findViewById(R.id.bAdd);
            sub=(Button)findViewById(R.id.bSub); 
            display=(TextView)findViewById(R.id.tvDisplay);
            add.setOnClickListener(new View.OnClickListener() {


                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    counter++;      
                    display.setText("Your total is "+counter);

                }
            });

            sub.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    counter--;
                    display.setText("Your total is "+counter);

                }

             });


        }//method
    }//class

    Finally the logcat:

06-17 18:51:51.427: E/AndroidRuntime(358): FATAL EXCEPTION: main
06-17 18:51:51.427: E/AndroidRuntime(358): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.thenewboaton.travis/com.thenewboaton.travis.abc}: java.lang.ClassNotFoundException: com.thenewboaton.travis.abc in loader dalvik.system.PathClassLoader[/data/app/com.thenewboaton.travis-1.apk]
06-17 18:51:51.427: E/AndroidRuntime(358):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1660)

so i tried varying the class names here and there and also the activity name. As soon as the emulator starts the error comes saying the Launcher has failed and the app doesn't start off at all .. i cant remember the EXACT change i did before this error started .. anyone can help me out on this ? I'd be glad if anyone can figure this out . thanks :)

4

2 回答 2

1

您需要指出AndroidManifestat MainActivity

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

或者,如果您的 Activity 称为abcsplash,并且位于您的主包中,您可以使用:

    <activity
        android:name=".abc"
        android:label="@string/app_name" >
        ...
    </activity>

    <activity
        android:name=".splash"
        android:label="@string/app_name" >
        ...
    </activity>
于 2013-06-17T13:39:15.950 回答
-1

您的清单指向两个活动:“abc”和“splash”,但您的源代码称为 MainActivity。将 MainActivity 改名为 abc 或编辑清单以指向 MainActivity 而不是 abc。

于 2013-06-17T13:38:39.623 回答