Java 如何使应用程序保持活动状态?运行后显示一个奇怪的错误

Java 如何使应用程序保持活动状态?运行后显示一个奇怪的错误,java,android,linux,dalvik,Java,Android,Linux,Dalvik,这是我的代码,我正在尝试在Android上运行。它运行,然后给出那个奇怪的错误对话框 package com.example.neon; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloNeon extends Activity { /** Called when the activity is first created.

这是我的代码,我正在尝试在Android上运行。它运行,然后给出那个奇怪的错误对话框

package com.example.neon;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloNeon extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        /* Create a TextView and set its content.
         * the text is retrieved by calling a native
         * function.
         */
        TextView  tv = new TextView(this);
        tv.setText( stringFromJNI() );
        setContentView(tv);
    }

    /* A native method that is implemented by the
     * 'helloneon' native library, which is packaged
     * with this application.
     */
    public native String  stringFromJNI();

    /* this is used to load the 'helloneon' library on application
     * startup. The library has already been unpacked into
     * /data/data/com.example.neon/lib/libhelloneon.so at
     * installation time by the package manager.
     */
    static {
        System.loadLibrary("helloneon");
    }
}

错误:

[2011-11-12 16:41:13 - HelloJni] Unable to resolve target 'android-8'
[2011-11-12 16:42:37 - HelloJni] ------------------------------
[2011-11-12 16:42:37 - HelloJni] Android Launch!
[2011-11-12 16:42:37 - HelloJni] adb is running normally.
[2011-11-12 16:42:37 - HelloJni] Performing com.example.hellojni.HelloJni activity launch
[2011-11-12 16:42:37 - HelloJni] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:42:45 - HelloJni] Uploading HelloJni.apk onto device '33c20c143608197'
[2011-11-12 16:42:45 - HelloJni] Installing HelloJni.apk...
[2011-11-12 16:42:46 - HelloJni] Success!
[2011-11-12 16:42:46 - HelloJni] Starting activity com.example.hellojni.HelloJni on device 33c20c143608197
[2011-11-12 16:42:46 - HelloJni] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.hellojni/.HelloJni }
[2011-11-12 16:43:31 - HelloJni] ------------------------------
[2011-11-12 16:43:31 - HelloJni] Android Launch!
[2011-11-12 16:43:31 - HelloJni] adb is running normally.
[2011-11-12 16:43:31 - HelloJni] Performing com.example.hellojni.HelloJni activity launch
[2011-11-12 16:43:31 - HelloJni] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:43:37 - HelloJni] Application already deployed. No need to reinstall.
[2011-11-12 16:43:37 - HelloJni] Starting activity com.example.hellojni.HelloJni on device 33c20c143608197
[2011-11-12 16:43:38 - HelloJni] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.hellojni/.HelloJni }
[2011-11-12 16:44:18 - HelloJni] ------------------------------
[2011-11-12 16:44:18 - HelloJni] Android Launch!
[2011-11-12 16:44:18 - HelloJni] adb is running normally.
[2011-11-12 16:44:18 - HelloJni] Performing com.example.hellojni.HelloJni activity launch
[2011-11-12 16:44:18 - HelloJni] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:44:23 - HelloJni] Application already deployed. No need to reinstall.
[2011-11-12 16:44:23 - HelloJni] Starting activity com.example.hellojni.HelloJni on device 33c20c143608197
[2011-11-12 16:44:23 - HelloJni] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.hellojni/.HelloJni }
[2011-11-12 16:45:01 - HelloNeon] Unable to resolve target 'android-3'
[2011-11-12 16:45:15 - HelloJni] ------------------------------
[2011-11-12 16:45:15 - HelloJni] Android Launch!
[2011-11-12 16:45:15 - HelloJni] adb is running normally.
[2011-11-12 16:45:15 - HelloJni] Performing com.example.hellojni.HelloJni activity launch
[2011-11-12 16:45:15 - HelloJni] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:45:17 - HelloJni] Application already deployed. No need to reinstall.
[2011-11-12 16:45:17 - HelloJni] Starting activity com.example.hellojni.HelloJni on device 33c20c143608197
[2011-11-12 16:45:17 - HelloJni] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.hellojni/.HelloJni }
[2011-11-12 16:45:36 - HelloJni] ------------------------------
[2011-11-12 16:45:36 - HelloJni] Android Launch!
[2011-11-12 16:45:36 - HelloJni] adb is running normally.
[2011-11-12 16:45:36 - HelloJni] Performing com.example.hellojni.HelloJni activity launch
[2011-11-12 16:45:36 - HelloJni] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:45:40 - HelloJni] Application already deployed. No need to reinstall.
[2011-11-12 16:45:40 - HelloJni] Starting activity com.example.hellojni.HelloJni on device 33c20c143608197
[2011-11-12 16:45:40 - HelloJni] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.hellojni/.HelloJni }
[2011-11-12 16:45:55 - HelloJni] ------------------------------
[2011-11-12 16:45:55 - HelloJni] Android Launch!
[2011-11-12 16:45:55 - HelloJni] adb is running normally.
[2011-11-12 16:45:55 - HelloJni] Performing com.example.hellojni.HelloJni activity launch
[2011-11-12 16:45:55 - HelloJni] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:45:58 - HelloJni] Application already deployed. No need to reinstall.
[2011-11-12 16:45:58 - HelloJni] Starting activity com.example.hellojni.HelloJni on device 33c20c143608197
[2011-11-12 16:45:58 - HelloJni] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.hellojni/.HelloJni }
[2011-11-12 16:46:16 - HelloNeon] ------------------------------
[2011-11-12 16:46:16 - HelloNeon] Android Launch!
[2011-11-12 16:46:16 - HelloNeon] adb is running normally.
[2011-11-12 16:46:16 - HelloNeon] Performing com.example.neon.HelloNeon activity launch
[2011-11-12 16:46:16 - HelloNeon] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:46:21 - HelloNeon] WARNING: Application does not specify an API level requirement!
[2011-11-12 16:46:21 - HelloNeon] Device API version is 11 (Android 3.0.1)
[2011-11-12 16:46:21 - HelloNeon] Uploading HelloNeon.apk onto device '33c20c143608197'
[2011-11-12 16:46:21 - HelloNeon] Installing HelloNeon.apk...
[2011-11-12 16:46:23 - HelloNeon] Success!
[2011-11-12 16:46:23 - HelloNeon] Starting activity com.example.neon.HelloNeon on device 33c20c143608197
[2011-11-12 16:46:23 - HelloNeon] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.neon/.HelloNeon }
[2011-11-12 16:46:34 - HelloNeon] ------------------------------
[2011-11-12 16:46:34 - HelloNeon] Android Launch!
[2011-11-12 16:46:34 - HelloNeon] adb is running normally.
[2011-11-12 16:46:34 - HelloNeon] Performing com.example.neon.HelloNeon activity launch
[2011-11-12 16:46:34 - HelloNeon] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:46:36 - HelloNeon] WARNING: Application does not specify an API level requirement!
[2011-11-12 16:46:36 - HelloNeon] Device API version is 11 (Android 3.0.1)
[2011-11-12 16:46:37 - HelloNeon] Application already deployed. No need to reinstall.
[2011-11-12 16:46:37 - HelloNeon] Starting activity com.example.neon.HelloNeon on device 33c20c143608197
[2011-11-12 16:46:37 - HelloNeon] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.neon/.HelloNeon }
[2011-11-12 16:46:55 - HelloNeon] ------------------------------
[2011-11-12 16:46:55 - HelloNeon] Android Launch!
[2011-11-12 16:46:55 - HelloNeon] adb is running normally.
[2011-11-12 16:46:55 - HelloNeon] Performing com.example.neon.HelloNeon activity launch
[2011-11-12 16:46:55 - HelloNeon] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:46:57 - HelloNeon] WARNING: Application does not specify an API level requirement!
[2011-11-12 16:46:57 - HelloNeon] Device API version is 11 (Android 3.0.1)
[2011-11-12 16:46:58 - HelloNeon] Application already deployed. No need to reinstall.
[2011-11-12 16:46:58 - HelloNeon] Starting activity com.example.neon.HelloNeon on device 33c20c143608197
[2011-11-12 16:46:58 - HelloNeon] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.neon/.HelloNeon }
[2011-11-12 16:47:07 - HelloNeon] ------------------------------
[2011-11-12 16:47:07 - HelloNeon] Android Launch!
[2011-11-12 16:47:07 - HelloNeon] adb is running normally.
[2011-11-12 16:47:07 - HelloNeon] Performing com.example.neon.HelloNeon activity launch
[2011-11-12 16:47:07 - HelloNeon] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:47:10 - HelloNeon] WARNING: Application does not specify an API level requirement!
[2011-11-12 16:47:10 - HelloNeon] Device API version is 11 (Android 3.0.1)
[2011-11-12 16:47:10 - HelloNeon] Application already deployed. No need to reinstall.
[2011-11-12 16:47:10 - HelloNeon] Starting activity com.example.neon.HelloNeon on device 33c20c143608197
[2011-11-12 16:47:10 - HelloNeon] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.neon/.HelloNeon }
[2011-11-12 16:49:15 - HelloNeon] ------------------------------
[2011-11-12 16:49:15 - HelloNeon] Android Launch!
[2011-11-12 16:49:15 - HelloNeon] adb is running normally.
[2011-11-12 16:49:15 - HelloNeon] Performing com.example.neon.HelloNeon activity launch
[2011-11-12 16:49:15 - HelloNeon] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:49:18 - HelloNeon] WARNING: Application does not specify an API level requirement!
[2011-11-12 16:49:18 - HelloNeon] Device API version is 11 (Android 3.0.1)
[2011-11-12 16:49:18 - HelloNeon] Application already deployed. No need to reinstall.
[2011-11-12 16:49:18 - HelloNeon] Starting activity com.example.neon.HelloNeon on device 33c20c143608197
[2011-11-12 16:49:19 - HelloNeon] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.neon/.HelloNeon }
[2011-11-12 16:52:11 - HelloNeon] ------------------------------
[2011-11-12 16:52:11 - HelloNeon] Android Launch!
[2011-11-12 16:52:11 - HelloNeon] adb is running normally.
[2011-11-12 16:52:11 - HelloNeon] Performing com.example.neon.HelloNeon activity launch
[2011-11-12 16:52:11 - HelloNeon] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:52:13 - HelloNeon] WARNING: Application does not specify an API level requirement!
[2011-11-12 16:52:13 - HelloNeon] Device API version is 11 (Android 3.0.1)
[2011-11-12 16:52:13 - HelloNeon] Application already deployed. No need to reinstall.
[2011-11-12 16:52:13 - HelloNeon] Starting activity com.example.neon.HelloNeon on device 33c20c143608197
[2011-11-12 16:52:13 - HelloNeon] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.neon/.HelloNeon }
[2011-11-12 16:58:47 - HelloNeon] ------------------------------
[2011-11-12 16:58:47 - HelloNeon] Android Launch!
[2011-11-12 16:58:47 - HelloNeon] adb is running normally.
[2011-11-12 16:58:47 - HelloNeon] Performing com.example.neon.HelloNeon activity launch
[2011-11-12 16:58:47 - HelloNeon] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2011-11-12 16:58:52 - HelloNeon] WARNING: Application does not specify an API level requirement!
[2011-11-12 16:58:52 - HelloNeon] Device API version is 11 (Android 3.0.1)
[2011-11-12 16:58:52 - HelloNeon] Application already deployed. No need to reinstall.
[2011-11-12 16:58:52 - HelloNeon] Starting activity com.example.neon.HelloNeon on device 33c20c143608197
[2011-11-12 16:58:53 - HelloNeon] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.neon/.HelloNeon }
当我运行时,屏幕上出现错误:

“Sorr!应用程序HellowNeon(process com.example.neon)意外停止。请重试。”

我猜错误是“应用程序HellowNeon(process com.example.neon)意外停止,请重试:-)”。所以你可以

将日志筛选为错误并查找致命异常


您还可以通过在Eclipse中设置断点进行调试。选择“调试”而不是标准的“运行”,这将允许您单步执行等等

啊,又是星期六“猜我的错”的时候了!请包括错误消息的文本和任何异常,而不是一张图片,其中文本一边不可读,另一边由于滚动条而不完整。我们无法阅读“奇怪的错误对话框”。我不熟悉这一点。在一步一步调试时,它会显示“警告:应用程序未指定API级别要求!”。将行:添加到您的清单中,就在AndroidManifest.xml中的结束清单标记之前。将3替换为您希望支持的最低数量的SDK版本。我看到它将其放在结束清单之前,如()标签。看一看,看一看