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

时间:2014-07-09 17:50:29

标签: java android eclipse android-emulator installation

我是Android开发的新手(请善待),我尝试在两台独立的机器上设置我的开发环境,一台配备AMD处理器,另一台配备英特尔处理器。在这两台机器上,我无法在模拟器中打开应用程序。我花了几个小时搜索问题,现在我需要帮助。

在我再说一遍之前,我想提一下,在我安装32位JDK之前,eclipse不能在我的机器上运行,即使我正在运行64位机器人的64位机器人安装。 (这可能与它有关吗?)

请查看我的imgur链接,了解我正在做的事情。 Imgur Link

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

在Package Explorer中,我右键单击,然后转到New> Android Application Project。

然后我更改了应用程序名称,包名称和最低要求的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>

1 个答案:

答案 0 :(得分:3)

您正在制作Android Wear项目,您真的想要吗?您是否尝试制作“正常”的Android项目?