java - Eclipse - Android 应用程序崩溃

标签 java android xml

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

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();
    }
}   
}

我的 list 也为

<?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>

最佳答案

您有一个拼写错误: <action android:name="**come**.example.first_app.MENU" />

您的意思是输入“com”而不是“come”

仅供引用:我发现这一点的方式是在错误日志中。该行:

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

发现处理 Intent 的 Activity { act=com.example.first_app.MENU }

显示您在您的应用中尝试创建一个名为“com.example.first_app.MENU”的 Activity ,但该 Activity 不是您项目的一部分。我希望你的 android list 根本没有该节点。但我发现那里有一个错字。希望对您有帮助。

关于java - Eclipse - Android 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16447201/

相关文章:

java - java中的窗口尺寸Gcanvas菜鸟问题

java - 为什么最终静态变量不能在实例 block 中赋值?

java - 无法在 Windows 上构建 Android 葫芦环境

c# - 如何使用 LINQ 获取 XML 元素的位置(按顺序索引)?

android - xml获取宽度并设置为android :height

java - Activity.class - 类文件编辑器 : The JAR file c:\sdk\platforms\android-17\android. jar 没有源附件

java - 如何获取Json数据

java - ClassNotFoundException,即使包含的 JAR 是构建的一部分

android - YouTube Player 内选项卡式 Activity

c++ - 用于存储设置的跨平台 C++ XML