android开发新手:android模拟器总是有应用程序崩溃



我是Android开发的新手(请友好),我尝试在两台不同的机器上设置我的开发环境,一台使用AMD处理器,另一台使用英特尔处理器。在两台机器上,我都无法在模拟器中打开应用程序。我花了好几个小时寻找这个问题,现在我需要帮助。

在我说更多之前,我想提一下eclipse不会在我的机器上运行,直到我安装了32位JDK,即使我运行的是一台安装了64位JDK的64位机器。(可能和这个有关系吗?)

请查看我的imgur链接来关注我在做什么。Imgur链接

让我告诉你们我在做什么,你们可以告诉我我做错了什么。

在Package Explorer中,我右键单击,然后转到新建>Android应用程序项目。

然后更改应用程序名称,包名称和最小所需SDK。

然后点击下一步,直到到达"创建活动"菜单,选中"创建活动"旁边的框,然后选择"空白活动"。

然后单击下一步,然后单击完成。

我认为这已经足够了,我应该能够在模拟器中运行它,所以为了测试模拟器,我然后选择运行配置,并选择我的应用程序,并选择"com.johndavisdesign.helloworld.MainActivity.

我将目标设置为模拟运行Android 4.4的Nexus 10的AVD。

这将启动模拟器,但不会安装程序,无论我等待多久。如果我在不关闭模拟器的情况下再次运行配置,程序将打开,但会说"不幸的是,HelloWorld已停止"。

我的控制台显示:

[2014-07-09 13:34:35 - HelloWorld] ------------------------------
[2014-07-09 13:34:35 - HelloWorld] Android Launch!
[2014-07-09 13:34:35 - HelloWorld] adb is running normally.
[2014-07-09 13:34:35 - HelloWorld] Performing com.johndavisdesign.helloworld.MainActivity activity launch
[2014-07-09 13:34:35 - HelloWorld] Automatic Target Mode: Preferred AVD 'Test' is not available. Launching new emulator.
[2014-07-09 13:34:35 - HelloWorld] Launching a new emulator with Virtual Device 'Test'
[2014-07-09 13:34:36 - Emulator] emulator: device fd:740
[2014-07-09 13:34:36 - Emulator] 
[2014-07-09 13:34:36 - Emulator] HAX is working and emulator runs in fast virt mode
[2014-07-09 13:34:36 - Emulator] creating window 0 0 1640 1025
[2014-07-09 13:34:36 - Emulator] emulator: emulator window was out of view and was recentered
[2014-07-09 13:34:36 - Emulator] 
[2014-07-09 13:34:36 - HelloWorld] New emulator found: emulator-5554
[2014-07-09 13:34:36 - HelloWorld] Waiting for HOME ('android.process.acore') to be launched...
[2014-07-09 13:35:07 - HelloWorld] ------------------------------
[2014-07-09 13:35:07 - HelloWorld] Android Launch!
[2014-07-09 13:35:07 - HelloWorld] adb is running normally.
[2014-07-09 13:35:07 - HelloWorld] Performing com.johndavisdesign.helloworld.MainActivity activity launch
[2014-07-09 13:35:07 - HelloWorld] Automatic Target Mode: Preferred AVD 'Test' is available on emulator 'emulator-5554'
[2014-07-09 13:35:07 - HelloWorld] Uploading HelloWorld.apk onto device 'emulator-5554'
[2014-07-09 13:35:08 - HelloWorld] Installing HelloWorld.apk...
[2014-07-09 13:35:08 - HelloWorld] Success!
[2014-07-09 13:35:08 - HelloWorld] Starting activity com.johndavisdesign.helloworld.MainActivity on device emulator-5554
[2014-07-09 13:35:08 - HelloWorld] ActivityManager: WARNING: linker: libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
[2014-07-09 13:35:08 - HelloWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.johndavisdesign.helloworld/.MainActivity }
[2014-07-09 13:35:21 - HelloWorld] HOME is up on device 'emulator-5554'
[2014-07-09 13:35:21 - HelloWorld] Application already deployed. No need to reinstall.
[2014-07-09 13:35:21 - HelloWorld] Starting activity com.johndavisdesign.helloworld.MainActivity on device emulator-5554
[2014-07-09 13:35:21 - HelloWorld] ActivityManager: WARNING: linker: libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
[2014-07-09 13:35:21 - HelloWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.johndavisdesign.helloworld/.MainActivity }

我的logcat文件读:

07-09 17:35:06.550: D/AndroidRuntime(1582): Shutting down VM
07-09 17:35:06.550: E/AndroidRuntime(1582): FATAL EXCEPTION: main
07-09 17:35:06.550: E/AndroidRuntime(1582): Process: com.johndavisdesign.helloworld, PID: 1582
07-09 17:35:06.550: E/AndroidRuntime(1582): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.johndavisdesign.helloworld/com.johndavisdesign.helloworld.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.os.Handler.dispatchMessage(Handler.java:102)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.os.Looper.loop(Looper.java:136)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.ActivityThread.main(ActivityThread.java:5026)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at java.lang.reflect.Method.invokeNative(Native Method)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at java.lang.reflect.Method.invoke(Method.java:515)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at dalvik.system.NativeStart.main(Native Method)
07-09 17:35:06.550: E/AndroidRuntime(1582): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-09 17:35:06.550: E/AndroidRuntime(1582):     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.Activity.setContentView(Activity.java:1930)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at com.johndavisdesign.helloworld.MainActivity.onCreate(MainActivity.java:14)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.Activity.performCreate(Activity.java:5242)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-09 17:35:06.550: E/AndroidRuntime(1582):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-09 17:35:06.550: E/AndroidRuntime(1582):     ... 11 more
07-09 17:35:06.550: W/dalvikvm(1582): threadid=1: thread exiting with uncaught exception (group=0xacd27ce8)
07-09 17:40:06.574: I/Process(1582): Sending signal. PID: 1582 SIG: 9
07-09 17:40:06.614: D/AndroidRuntime(1637): Shutting down VM
07-09 17:40:06.614: E/AndroidRuntime(1637): FATAL EXCEPTION: main
07-09 17:40:06.614: E/AndroidRuntime(1637): Process: com.johndavisdesign.helloworld, PID: 1637
07-09 17:40:06.614: E/AndroidRuntime(1637): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.johndavisdesign.helloworld/com.johndavisdesign.helloworld.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.os.Handler.dispatchMessage(Handler.java:102)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.os.Looper.loop(Looper.java:136)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.ActivityThread.main(ActivityThread.java:5026)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at java.lang.reflect.Method.invokeNative(Native Method)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at java.lang.reflect.Method.invoke(Method.java:515)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at dalvik.system.NativeStart.main(Native Method)
07-09 17:40:06.614: E/AndroidRuntime(1637): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-09 17:40:06.614: E/AndroidRuntime(1637):     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.Activity.setContentView(Activity.java:1930)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at com.johndavisdesign.helloworld.MainActivity.onCreate(MainActivity.java:14)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.Activity.performCreate(Activity.java:5242)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-09 17:40:06.614: E/AndroidRuntime(1637):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-09 17:40:06.614: E/AndroidRuntime(1637):     ... 11 more
07-09 17:40:06.614: W/dalvikvm(1637): threadid=1: thread exiting with uncaught exception (group=0xacd27ce8)

我做错了什么?

编辑:

下面是MainActivity.java:

package com.johndavisdesign.helloworld;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

}

编辑2:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.johndavisdesign.helloworld.MainActivity" >
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />
</RelativeLayout>

你正在做一个Android Wear项目,你真的想这样吗?你试过做一个"普通的"Android项目吗?

相关内容

最新更新