1

I'm trying to launch my android application. Unfortunately I messed around it a bit too much by deleting the main activity and messing around the manifest.

I tried to make the application to start up on my menu activity first and i figured i wouldn't need the main activity. here's the manifest

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

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.taekwondobuddy.Menu"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/app_name"
        android:theme="@style/FullscreenTheme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

</manifest>

and here's the menu class, even though I think its unnecessary

       package com.example.taekwondobuddy.util;        
      import android.app.ListActivity;
     import android.content.Intent;
     import android.os.Bundle;
      import android.view.View;
    import android.widget.ArrayAdapter;
     import android.widget.ListView;

    public class Menu extends ListActivity {

String classes[] = {"Tool","Techniques","Tkd Buddy"} ;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_list_item_1, classes));
}


@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    // TODO Auto-generated method stub
    super.onListItemClick(l, v, position, id);
    String cheese = classes[position];
    try{
    Class ourclass = Class.forName("com.example.taekwondobuddy" + cheese);
    Intent ourIntent = new Intent(Menu.this, ourclass);
    startActivity(ourIntent);
    } catch(ClassNotFoundException e){
        e.printStackTrace();

    }
}




  }

heres the console notes too

                     [2013-10-16 14:13:44 - TaekwondoBuddy] Android Launch!
 [2013-10-16 14:13:44 - TaekwondoBuddy] adb is running normally.
 [2013-10-16 14:13:44 - TaekwondoBuddy] Performing com.example.taekwondobuddy.Menu    activity launch
 [2013-10-16 14:13:44 - TaekwondoBuddy] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'droidx'
[2013-10-16 14:13:44 - TaekwondoBuddy] Uploading TaekwondoBuddy.apk onto device 'emulator-5554'
[2013-10-16 14:13:48 - TaekwondoBuddy] Installing TaekwondoBuddy.apk...
[2013-10-16 14:13:53 - TaekwondoBuddy] Success!
[2013-10-16 14:13:53 - TaekwondoBuddy] Starting activity com.example.taekwondobuddy.Menu on device emulator-5554
[2013-10-16 14:13:54 - TaekwondoBuddy] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.taekwondobuddy/.Menu }

      and log cat 
              10-16 18:03:57.653: E/AndroidRuntime(362): FATAL EXCEPTION: main
           10-16 18:03:57.653: E/AndroidRuntime(362): java.lang.RuntimeException:  Unable to instantiate activity    ComponentInfo{com.example.taekwondobuddy/com.example.taekwondobuddy.Menu}:  java.lang.ClassNotFoundException: com.example.taekwondobuddy.Menu in loader dalvik.system.PathClassLoader[/data/app/com.example.taekwondobuddy-2.apk]
                 10-16 18:03:57.653: E/AndroidRuntime(362):     at    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
      10-16 18:03:57.653: E/AndroidRuntime(362):    at  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
     10-16 18:03:57.653: E/AndroidRuntime(362):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
      10-16 18:03:57.653: E/AndroidRuntime(362):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
     10-16 18:03:57.653: E/AndroidRuntime(362):     at android.os.Handler.dispatchMessage(Handler.java:99)
     10-16 18:03:57.653: E/AndroidRuntime(362):     at android.os.Looper.loop(Looper.java:123)
    10-16 18:03:57.653: E/AndroidRuntime(362):  at android.app.ActivityThread.main(ActivityThread.java:4627)
     10-16 18:03:57.653: E/AndroidRuntime(362):     at    java.lang.reflect.Method.invokeNative(Native Method)
   10-16 18:03:57.653: E/AndroidRuntime(362):   at java.lang.reflect.Method.invoke(Method.java:521)
   10-16 18:03:57.653: E/AndroidRuntime(362):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-16 18:03:57.653: E/AndroidRuntime(362):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
      10-16 18:03:57.653: E/AndroidRuntime(362):    at dalvik.system.NativeStart.main(Native Method)
     10-16 18:03:57.653: E/AndroidRuntime(362): Caused by: java.lang.ClassNotFoundException: com.example.taekwondobuddy.Menu in loader dalvik.system.PathClassLoader[/data/app/com.example.taekwondobuddy-2.apk]
    10-16 18:03:57.653: E/AndroidRuntime(362):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
    10-16 18:03:57.653: E/AndroidRuntime(362):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
    10-16 18:03:57.653: E/AndroidRuntime(362):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
      10-16 18:03:57.653: E/AndroidRuntime(362):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
  10-16 18:03:57.653: E/AndroidRuntime(362):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
   10-16 18:03:57.653: E/AndroidRuntime(362):   ... 11 more

and it'll run the app but tells me the application has stopped unexpectedly

I think it something in the manifest, is it trying to find the Main activity class that I deleted and if it is how can I make it so that this menu class will be my new main activity?

user2809321
  • 196
  • 1
  • 3
  • 17
  • What exactly is the problem you are experiencing? Does the application not show up in the app drawer of the device? Or it just doesn't launch automatically when you run it from your IDE? – devunwired Oct 16 '13 at 18:29
  • is there `package com.example.taekwondobuddy;` in that `Menu` class? It won't find it if it's not in the right package. Also `"Tkd Buddy"` is an impossible class name and you are missing the last `.` in `Class.forName` – zapl Oct 16 '13 at 18:32
  • @zapl yes there is the package there I just forgot to included in code I'll do it right away – user2809321 Oct 16 '13 at 18:34
  • @Devunwired Yeah it will run on the adroid simulator but it'll tell me it has encountered an unexpected problem and forces me to close the app I'll post the console notes – user2809321 Oct 16 '13 at 18:36
  • Console is all fine, the app did start the `Menu` activity. But it crashed in there. You will find that error in [`LogCat`](http://stackoverflow.com/q/3280051/995891) – zapl Oct 16 '13 at 18:46
  • @zapl this is the error but have no idea what it means 10-16 18:38:33.804: E/AndroidRuntime(494): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577) – user2809321 Oct 16 '13 at 18:53
  • This is just part of the error, there is a reason for that error below that. Please add the entire thing to your question. – zapl Oct 16 '13 at 19:11
  • @zapl posted the log cat – user2809321 Oct 16 '13 at 19:33
  • 1
    @user2809321: Your Manifest declaration shows tha ur class package is com.example.taekwondobuddy...however actual pakage is the class is com.example.taekwondobuddy.util.. – Shashank Kadne Oct 16 '13 at 19:47
  • yes thank you it was the package name in the manifest, I had to add the util – user2809321 Oct 16 '13 at 20:03

0 Answers0