微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – 不幸的是,(App Name)已经停止了. Eclipse / Android

我是eclipse的新手,想知道如何保留这个信息

Unfortunately, (App Name) has stopped." 

每次我在AVD中运行我的测试应用程序时显示.我正在尝试制作LineView布局,Eclipse显示没有错误.那么如何解决这个问题呢?如果Eclipse没有显示问题,如何找出问题所在呢?

(这是我的Logcat的副本)

05-29 23:49:12.604: D/AndroidRuntime(832): Shutting down VM
05-29 23:49:12.675: W/dalvikvm(832): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
05-29 23:49:12.775: E/AndroidRuntime(832): FATAL EXCEPTION: main
05-29 23:49:12.775: E/AndroidRuntime(832): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{testing.android.application.three/testing.android.application.three.MainActivityThreeActivity}: java.lang.classNotFoundException: Didn't find class "testing.android.application.three.MainActivityThreeActivity" on path: /data/app/testing.android.application.three-1.apk
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2106)
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.os.Looper.loop(Looper.java:137)
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.app.ActivityThread.main(ActivityThread.java:5041)
05-29 23:49:12.775: E/AndroidRuntime(832):  at java.lang.reflect.Method.invokeNative(Native Method)
05-29 23:49:12.775: E/AndroidRuntime(832):  at java.lang.reflect.Method.invoke(Method.java:511)
05-29 23:49:12.775: E/AndroidRuntime(832):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-29 23:49:12.775: E/AndroidRuntime(832):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-29 23:49:12.775: E/AndroidRuntime(832):  at dalvik.system.NativeStart.main(Native Method)
05-29 23:49:12.775: E/AndroidRuntime(832): Caused by: java.lang.classNotFoundException: Didn't find class "testing.android.application.three.MainActivityThreeActivity" on path: /data/app/testing.android.application.three-1.apk
05-29 23:49:12.775: E/AndroidRuntime(832):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-29 23:49:12.775: E/AndroidRuntime(832):  at java.lang.classLoader.loadClass(ClassLoader.java:501)
05-29 23:49:12.775: E/AndroidRuntime(832):  at java.lang.classLoader.loadClass(ClassLoader.java:461)
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
05-29 23:49:12.775: E/AndroidRuntime(832):  at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2097)
05-29 23:49:12.775: E/AndroidRuntime(832):  ... 11 more
05-29 23:49:30.595: E/Trace(851): error opening trace file: No such file or directory (2)
05-29 23:49:30.965: D/AndroidRuntime(851): Shutting down VM
05-29 23:49:31.015: W/dalvikvm(851): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
05-29 23:49:31.075: E/AndroidRuntime(851): FATAL EXCEPTION: main
05-29 23:49:31.075: E/AndroidRuntime(851): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{testing.android.application.three/testing.android.application.three.MainActivityThreeActivity}: java.lang.classNotFoundException: Didn't find class "testing.android.application.three.MainActivityThreeActivity" on path: /data/app/testing.android.application.three-1.apk
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2106)
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.os.Looper.loop(Looper.java:137)
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.app.ActivityThread.main(ActivityThread.java:5041)
05-29 23:49:31.075: E/AndroidRuntime(851):  at java.lang.reflect.Method.invokeNative(Native Method)
05-29 23:49:31.075: E/AndroidRuntime(851):  at java.lang.reflect.Method.invoke(Method.java:511)
05-29 23:49:31.075: E/AndroidRuntime(851):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-29 23:49:31.075: E/AndroidRuntime(851):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-29 23:49:31.075: E/AndroidRuntime(851):  at dalvik.system.NativeStart.main(Native Method)
05-29 23:49:31.075: E/AndroidRuntime(851): Caused by: java.lang.classNotFoundException: Didn't find class "testing.android.application.three.MainActivityThreeActivity" on path: /data/app/testing.android.application.three-1.apk
05-29 23:49:31.075: E/AndroidRuntime(851):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
05-29 23:49:31.075: E/AndroidRuntime(851):  at java.lang.classLoader.loadClass(ClassLoader.java:501)
05-29 23:49:31.075: E/AndroidRuntime(851):  at java.lang.classLoader.loadClass(ClassLoader.java:461)
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
05-29 23:49:31.075: E/AndroidRuntime(851):  at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2097)
05-29 23:49:31.075: E/AndroidRuntime(851):  ... 11 more
05-29 23:49:35.207: I/Process(851): Sending signal. PID: 851 SIG: 9

(这是我的activity_main_activity_three.xml的副本)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_horizontal_margin"
    android:paddingLeft="@dimen/activity_vertical_margin"
    android:paddingRight="@dimen/activity_vertical_margin"
    android:paddingTop="@dimen/activity_horizontal_margin"
    tools:context=".MainActivityThree" >
</LinearLayout>

(这是我的MainActivityThree.java的副本)

package testing.android.application.three;

import android.os.Bundle;
import android.app.ListActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivityThree extends ListActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_main_activity_three);
        String[] names = new String[]{"Text 1","Text 2","Text 3","Text 4","Text 5","Text"};
        setlistadapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,names));   
    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // Todo Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        Object o = this.getlistadapter().getItem(position);
        String keyword = o.toString();
        Toast.makeText(this, "Test 1" + keyword, Toast.LENGTH_LONG).show();
    }
}

(这是我的ThreeManifest的副本)

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:label="@string/AppName"
        android:icon="@drawable/ic_launcher"
        android:theme="@style/ThreeTheme">
        <activity
            android:name="testing.android.application.three.MainActivityThreeActivity"
            android:label="@string/AppName" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

解决方法:

查看LogCat和清单,可以看到活动类的名称与清单文件显示的类的名称不同.

因此,为了解决问题,请在清单中更改此行

android:name="testing.android.application.three.MainActivityThreeActivity"

对于

android:name="testing.android.application.three.MainActivityThree"

这可以解决问题!

请记住AndroidManifest文件“管理”您的应用程序.您要使用的每个服务和活动或您的应用程序所需的每个权限,您都必须在清单文件注册并正确执行,否则,您将遇到类似的崩溃.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐