0

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.

vpaladino778
  • 157
  • 14
  • Wow alright i didn't even realize that i made a typo in example. Another error is popping up though. `Description Resource Path Location Type The project was not built due to "A resource exists with a different case: '/FirstApp/bin/classes/com/examle/firstapp'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent FirstApp Unknown Java Problem` – vpaladino778 Jun 08 '13 at 15:57
  • what's the package name in your java files?. Seems to be mismatch of the package name. is it like `package com.example.firstapp;` – Raghunandan Jun 08 '13 at 16:01
  • The package name had caps in it, i just fixed it now. Now that error is gone, but now when i try to run the app, the splash screen doesn't show up at all, and it tells me it has stopped working. – vpaladino778 Jun 08 '13 at 16:08
  • did you try the edit's mentioned in my answer? Post he new logcat details of the crash – Raghunandan Jun 08 '13 at 16:09
  • Yeah i tried them, no luck. – vpaladino778 Jun 08 '13 at 16:12
  • post the new logcat details of the crash – Raghunandan Jun 08 '13 at 16:13
  • Alright i just edited the log cat the in main post because it was too long for the comments. So the log cat that's in the main post now, is what is showing up currently. – vpaladino778 Jun 08 '13 at 16:18
  • post the new manifest code also – Raghunandan Jun 08 '13 at 16:19
  • also if you have updated your adt tool to rev 22. check this http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra – Raghunandan Jun 08 '13 at 16:20
  • Here it is, http://pastebin.com/7KgZvkk0 – vpaladino778 Jun 08 '13 at 16:23
  • your manifest seems alright to me try the link i posted in the above comment – Raghunandan Jun 08 '13 at 16:25
  • Well i downloaded the ADT Bundle about a week ago, so i'm not sure what version it is. Ill try updating it though. – vpaladino778 Jun 08 '13 at 16:25
  • Android SDK build Tools is at rev 17, android sdk tools is at rev 22.01 – vpaladino778 Jun 08 '13 at 16:28
  • Right click on your project goto properties. Java Build Path. Choose Order export tab. Make sure that Android Private Libraries is selected. Clean and Build. – Raghunandan Jun 08 '13 at 16:29
  • Yeah it's checked, i cleaned and built the project, still i get a bunch of errors. – vpaladino778 Jun 08 '13 at 16:35
  • post those errors. i suggest you go through the link posted in my answer – Raghunandan Jun 08 '13 at 16:38
  • I went through the intructions on the link and didn't get any results. Here are the errors http://pastebin.com/aTBRAyhE – vpaladino778 Jun 08 '13 at 16:44
  • post your java files also. i don't see anything wrong with the manifest file – Raghunandan Jun 08 '13 at 17:33
  • Alright, here is my Splash.java http://pastebin.com/7kGAM3S3 And here is my MainActivity.java http://pastebin.com/4vAmMeZm Btw, thanks for your help so far, i really appreciate it. – vpaladino778 Jun 08 '13 at 18:19
  • Alright so i believed i fixed several minor mistakes, so not the it goes to the splash screen fine, and then crashes. Here is my new MainActivity.xml http://pastebin.com/AVypsYzv Here is my new Splash.xml http://pastebin.com/p7SxLhQA – vpaladino778 Jun 09 '13 at 00:35
  • Intent openMainActivity = new Intent("com.examle.firstapp.MAINACTIVITY"); should be Intent openMainActivity = new Intent("com.example.firstapp.MainActivity"); in your splash screen. using sleep inside a timer is bad design. use a handler http://stackoverflow.com/questions/16643177/changing-image-in-imageview-using-threads/16643564#16643564. – Raghunandan Jun 09 '13 at 03:52
  • i fixed what you suggested with the intent, still with no luck. I dont really want to change it to a handler just because i want to stick to the tutorial series I'm going through. – vpaladino778 Jun 09 '13 at 15:19
  • Alright so I've found that is i run MainACitvity without it going through the splash, it works, and when i run Splash, it works fine, but once it transitions to main activity, it stops working. – vpaladino778 Jun 10 '13 at 12:02
  • use a handler and try this link http://stackoverflow.com/questions/16643177/changing-image-in-imageview-using-threads/16643564#16643564. still have doubts start a new question. accept the below answer first and start a new thread. too much commenting leading to discussion – Raghunandan Jun 10 '13 at 12:04
  • Alright i got it to work, one of the paths in the Finally statement wasn't the same as the path in the android manifest. Thanks for your help everyone, i appreciate the effort. – vpaladino778 Jun 10 '13 at 12:06

5 Answers5

3

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"
afarazit
  • 4,907
  • 2
  • 27
  • 51
MungoRae
  • 1,912
  • 1
  • 16
  • 25
  • You also need to make sure that the first line of your Java files, which also states the package, match the package name in your manifest. Make sure its consistant. – MungoRae Jun 08 '13 at 19:57
  • Turns out that i actually named the actual package file 'examle' and i didn't even realize it. Thanks anyway though. – vpaladino778 Jun 09 '13 at 00:58
2
 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" /> 
CRUSADER
  • 5,486
  • 3
  • 28
  • 64
vs.thaakur
  • 619
  • 3
  • 13
1

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"\>
verybadalloc
  • 5,768
  • 2
  • 33
  • 49
0

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

Raghunandan
  • 132,755
  • 26
  • 225
  • 256
0

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