0

I'm pretty new to this whole Android programming thing, and I'm having a problem where the app quits out after I build it. After a few seconds, it quits out of the app displaying a message that says, "Unfortunately, the app has stopped." In addition to this, LogCat freaks out after this, and prints out a seemingly endless list of problems, which I'll post here. I saw a few other posts about this on stackoverflow, but I haven't found one that solves my problem. Any help would be greatly appreciated - thank you very much!

07-02 08:51:33.208: D/AndroidRuntime(2639): Shutting down VM
07-02 08:51:33.208: W/dalvikvm(2639): threadid=1: thread exiting with uncaught exception (group=0x411b4ac8)
07-02 08:51:33.208: E/AndroidRuntime(2639): FATAL EXCEPTION: main
07-02 08:51:33.208: E/AndroidRuntime(2639): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.helloworldtaketwo/com.example.helloworldtaketwo.main}: java.lang.ClassNotFoundException: Didn't find class "com.example.helloworldtaketwo.main" on path: /data/app/com.example.helloworldtaketwo-2.apk
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.app.ActivityThread.access$700(ActivityThread.java:154)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.os.Looper.loop(Looper.java:137)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.app.ActivityThread.main(ActivityThread.java:5306)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at java.lang.reflect.Method.invokeNative(Native Method)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at java.lang.reflect.Method.invoke(Method.java:511)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at dalvik.system.NativeStart.main(Native Method)
07-02 08:51:33.208: E/AndroidRuntime(2639): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.helloworldtaketwo.main" on path: /data/app/com.example.helloworldtaketwo-2.apk
07-02 08:51:33.208: E/AndroidRuntime(2639):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.app.Instrumentation.newActivity(Instrumentation.java:1071)
07-02 08:51:33.208: E/AndroidRuntime(2639):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2166)
07-02 08:51:33.208: E/AndroidRuntime(2639):     ... 11 more
07-02 08:51:42.127: I/Process(2639): Sending signal. PID: 2639 SIG: 9

My Android Manifest looks something like this:

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

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

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

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

</manifest>

main.java

package thatpackage;

import com.example.helloworldtaketwo.R;

import android.app.Activity;
import android.os.Bundle;

public class main extends Activity{

    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

}
fabian
  • 80,457
  • 12
  • 86
  • 114
Humphrey
  • 25
  • 1
  • 7

2 Answers2

1

Your "main" activity must be located in the "com.example.helloworldtaketwo" package. Not a sub-package, not in a different place.

The problem here is that your activity isn't being found. Make sure it's properly linked by either placing it in the correct package, or correcting the manifest to point to the correct package.

Gil Moshayof
  • 16,633
  • 4
  • 47
  • 58
0

You have not declared the class in your manifest. Use this:

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

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".main"
        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.MyActivity2"></activity>


</application>

</manifest>

For more info Study these sources

Community
  • 1
  • 1
Vivek Warde
  • 1,936
  • 8
  • 47
  • 77