2013-05-08 94 views
0

我最近开始学习如何使用eclipse开发应用,我为它制作了一个应用和一个菜单。打开应用程序后,我得到应该保持5秒钟的启动屏幕,然后进入菜单。启动屏幕后,应用程序崩溃。我正在开发4.1.2。我的日志猫报告如下Eclipse - Android应用崩溃

05-08 13:46:21.170: V/MediaPlayer(16864): message received msg=2, ext1=0, ext2=0 

05-08 13:46:21.170: V/MediaPlayer(16864): playback complete 

05-08 13:46:21.170: V/MediaPlayer(16864): callback application 

05-08 13:46:21.170: V/MediaPlayer(16864): back from callback 

05-08 13:46:23.585: D/Instrumentation(16864): 
checkStartActivityResult :Intent { act=com.example.first_app.MENU } 

05-08 13:46:23.585: D/Instrumentation(16864): 
checkStartActivityResult inent is instance of inent: 

05-08 13:46:23.590: W/dalvikvm(16864): threadid=11: thread exiting with uncaught exception (group=0x40f122a0) 
05-08 13:46:23.590: E/AndroidRuntime(16864): FATAL EXCEPTION: Thread-1262 

05-08 13:46:23.590: E/AndroidRuntime(16864): android.content.ActivityNotFoundException: No 
Activity found to handle Intent { act=com.example.first_app.MENU } 

05-08 13:46:23.590: E/AndroidRuntime(16864): at 

android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1580) 
05-08 13:46:23.590: E/AndroidRuntime(16864): at 

android.app.Instrumentation.execStartActivity(Instrumentation.java:1431) 
05-08 13:46:23.590: E/AndroidRuntime(16864): at 

android.app.Activity.startActivityForResult(Activity.java:3446) 
05-08 13:46:23.590: E/AndroidRuntime(16864): at 

android.app.Activity.startActivityForResult(Activity.java:3407) 
05-08 13:46:23.590: E/AndroidRuntime(16864): at 

android.app.Activity.startActivity(Activity.java:3617) 
05-08 13:46:23.590: E/AndroidRuntime(16864): at 

android.app.Activity.startActivity(Activity.java:3585) 
05-08 13:46:23.590: E/AndroidRuntime(16864): at 

com.example.first_app.Splash$1.run(Splash.java:28) 

05-08 13:46:23.615: V/MediaPlayer-JNI(16864): release 

05-08 13:46:23.615: V/MediaPlayer(16864): setListener 

05-08 13:46:23.615: V/MediaPlayer(16864): disconnect 

05-08 13:46:23.620: V/MediaPlayer(16864): destructor 

05-08 13:46:23.620: V/MediaPlayer(16864): disconnect 

我的代码是

package com.example.first_app; 

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[] = {"startingPoint", "example1", "example2", "example3", "example4", "example5", "example6"}; 



@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.first_app." + cheese); 
    Intent ourIntent = new Intent(Menu.this, ourClass); 
    startActivity(ourIntent); 
    }catch(ClassNotFoundException e){ 
     e.printStackTrace(); 
    } 
} 
} 

,我也有我的表现为

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

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

<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="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".startingPoint" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="com.example.first_app" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".Menu" android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="come.example.first_app.MENU" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
     </intent-filter> 
    </activity> 
</application> 
</manifest> 
+1

发布您的代码,以便任何人都可以调试 – 2013-05-08 18:01:46

+1

您正在调用不存在的称为com.example.first_app.MENU的意图。确保您正确命名,并且将活动添加到清单中。除此之外,您需要发布代码。 – 2013-05-08 18:02:19

+0

你在'menu'的'manifest'中有'intent filter'吗? – codeMagic 2013-05-08 18:02:37

回答

1

你有一个错字: <action android:name="**come**.example.first_app.MENU" />

你打算输入“com”而不是“来”

而且仅供参考:我发现错误日志的方式。行:

05-08 13:46:23.590: E/AndroidRuntime(16864): android.content.ActivityNotFoundException: No 

活动中发现处理意向{行动= com.example.first_app.MENU}

让我发现,在你的应用程序,你试图创建一个名为活动“com.example.first_app .MENU“,但该活动不属于您的项目。我预计你的Android清单根本没有那个节点。但我发现它在那里有一个错字。希望能帮助你。