vpaladino778
vpaladino778

Reputation: 157

My Android app splash screen launches in the android emulator, but then the actual app never shows

When i try to run my app, the splash screen comes up correctly, and right after it closes, a message pops up that says "Unfortunatly, First app has stopped working" I've tried a ton of different solutions I've found but i believe in my case, it's a problem with my code after testing a new "Hello World" app within the emulator. Here's a copy of my androidmanifest.xml

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >


        <activity
            android:name=".Splash" android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.firstapp.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

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

    </application>

</manifest>

Here is what comes up in log cat after trying some of the solutions

    06-08 16:12:06.849: E/AndroidRuntime(2821): FATAL EXCEPTION: main
06-08 16:12:06.849: E/AndroidRuntime(2821): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.firstapp/com.example.firstapp.Splash}: java.lang.ClassNotFoundException: Didn't find class "com.example.firstapp.Splash" on path: /data/app/com.example.firstapp-1.apk
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.os.Looper.loop(Looper.java:137)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.main(ActivityThread.java:5041)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at java.lang.reflect.Method.invokeNative(Native Method)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at java.lang.reflect.Method.invoke(Method.java:511)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at dalvik.system.NativeStart.main(Native Method)
06-08 16:12:06.849: E/AndroidRuntime(2821): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.firstapp.Splash" on path: /data/app/com.example.firstapp-1.apk
06-08 16:12:06.849: E/AndroidRuntime(2821):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
06-08 16:12:06.849: E/AndroidRuntime(2821):     ... 11 more

I'm really quite new to android programming, so if you could be specific when assisting me it would be greatly appreciated.

Upvotes: 0

Views: 1845

Answers (5)

verybadalloc
verybadalloc

Reputation: 5798

In this case, the error lies in your manifest. The package name must be:

package="com.example.firstapp"

Also, for MainActivity, try to remove this:

<action android:name="android.intent.action.MAINACTIVTY"\>

Upvotes: 1

user4356416
user4356416

Reputation:

You can two step follow: 1. Uninstall previous (same) apps if install in your android phone. 2. Delete gen + bin folder then again after a few time run your apps in your android phone. Thanks

Upvotes: 0

vs.thaakur
vs.thaakur

Reputation: 619

 public class SplashScreenActivity extends Activity {
    /** Called when the activity is first created. */
    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Timer timer=new Timer();
        timer.schedule(new MyTask(), 5000);
    }


    class MyTask extends TimerTask{

        @Override
        public void run() {
            Intent intent=new  Intent(SplashScreenActivity.this,SecondActivity.class);
            finish();
            startActivity(intent);
        }

    }

}

in manifest

<intent-filter>
  <action android:name="android.intent.action.MAIN" /> 
  <category android:name="android.intent.category.LAUNCHER" /> 
  </intent-filter>`enter code here`
  </activity>
  <activity android:name=".SecondActivity" /> 

Upvotes: 2

MungoRae
MungoRae

Reputation: 1992

I believe that it can't find your main activity because you have spelled the example wrong in your manifest on the line:

package="com.examle.firstapp"

should be:

package="com.example.firstapp"

Upvotes: 3

Raghunandan
Raghunandan

Reputation: 133560

Assuming Splash in the default main activity to be launched. Your manifest should be

Your package name should be

 package="com.example.firstapp"

Activity

 <activity
        android:name="com.example.firstapp.Splash"
        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.example.firstapp.MainActivity"  
        android:label="@string/app_name" >
         <intent-filter>
            <action android:name="com.example.firstapp.MainActivity" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

If you have explicit intents you can skip the intent filter

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

For more info check the link's below

http://developer.android.com/guide/topics/manifest/manifest-intro.html

http://developer.android.com/guide/topics/manifest/manifest-element.html

Upvotes: 0

Related Questions