应用程序sati(进程com.example.sati)意外停止。请再试一次

时间:2014-03-24 13:29:15

标签: java android eclipse syntax-error

我正在创建一个应用程序,其中有一个包含要在运行应用程序时显示的图像的启动类,而另一个类用于添加和减去数字,并且在首先显示图像后显示。 ......

的manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sati"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />// here shows a warning saying"Not targeting the            latest versions of Android; compatibility modes apply. Consider testing and updating this         version. Consult the android.os.Build.VERSION_CODES javadoc for details."

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".SplashAct"
//it's the class 'splash' containing an image that shows up on start of an app
        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=".MainActivity"//it's a class that will appear after 'splash class' 
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.example.sati.MAINACTIVITY" />

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

</manifest>
following is the code of xml file named splash
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" 
android:background="@drawable/splash">
</LinearLayout>

Splash.java

package com.example.sati;

import android.app.Activity;

import android.os.Bundle;

public class Splash extends Activity {

@Override
protected void onCreate(Bundle sidra) {
    // TODO Auto-generated method stub
    super.onCreate(sidra);
    setContentView(R.layout.splash);//SPLASH CLASS CODE


}

 } 

   //all above mentioned code is the implementation of ThenewBoston tutorials up to 14

logcat的

    03-24 13:26:23.285: W/dalvikvm(328): threadid=1: thread exiting with uncaught exception    (group=0x4001d800)
    03-24 13:26:23.355: E/AndroidRuntime(328): FATAL EXCEPTION: main
    03-24 13:26:23.355: E/AndroidRuntime(328): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.sati/com.example.sati.SplashAct}: java.lang.ClassNotFoundException: com.example.sati.SplashAct in loader dalvik.system.PathClassLoader[/data/app/com.example.sati-1.apk]
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.os.Handler.dispatchMessage(Handler.java:99)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.os.Looper.loop(Looper.java:123)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.app.ActivityThread.main(ActivityThread.java:4 627)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at java.lang.reflect.Method.invokeNative(Native Method)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at java.lang.reflect.Method.invoke(Method.java:521)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at dalvik.system.NativeStart.main(Native Method)
    03-24 13:26:23.355: E/AndroidRuntime(328): Caused by: java.lang.ClassNotFoundException: com.example.sati.SplashAct in loader dalvik.system.PathClassLoader[/data/app/com.example.sati-1.apk]
    03-24 13:26:23.355: E/AndroidRuntime(328):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    03-24 13:26:23.355: E/AndroidRuntime(328):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
    03-24 13:26:23.355: E/AndroidRuntime(328):  ... 11 more

2 个答案:

答案 0 :(得分:1)

Caused by: java.lang.ClassNotFoundException: com.example.sati.SplashAct

你有

public class Splash extends Activity { // Activity Name is Splash not SplashAct

所以改变这个

<activity
    android:name=".SplashAct"

<activity
    android:name=".Splash"

答案 1 :(得分:0)

您的清单声称活动类SplashAct,但您发布的代码只有Splash。确保清单和代码具有相同的完整类名。