我正在尝试启动我的Android应用程序。不幸的是,通过删除主要活动并弄清楚清单,我搞砸了一下。
我试图让应用程序首先启动我的菜单活动,我想我不需要主要的活动。这是清单
<?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>
这里是菜单类,即使我认为它是不必要的
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();
}
}
}
控制台也注意到了
[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
并且它将运行应用程序,但告诉我应用程序已意外停止
我认为清单中的内容是,它是否正在尝试找到我删除的主要活动类,如果它是如何创建它以便此菜单类将成为我的新主要活动?