简体   繁体   English

应用程序在Eclipse中的模拟器中无法正常工作

[英]app not working in emulator in eclipse

I am new to this and i saw some tutorial and set up my emulator and all but when i run the hello world program the emulator says unfortunately the app has stopped 我对此并不陌生,我看了一些教程并设置了模拟器,但在运行hello world程序时,模拟器却说该应用程序已停止

this is what my console looks like 这就是我的控制台的样子

[2014-08-01 23:43:21 - SagarAppProject] Android Launch!
[2014-08-01 23:43:21 - SagarAppProject] adb is running normally.
[2014-08-01 23:43:21 - SagarAppProject] Performing com.sagarappproject.MainActivity activity launch
[2014-08-01 23:43:21 - SagarAppProject] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'DroidX'
[2014-08-01 23:43:21 - SagarAppProject] Uploading SagarAppProject.apk onto device 'emulator-5554'
[2014-08-01 23:43:21 - SagarAppProject] Installing SagarAppProject.apk...
[2014-08-01 23:43:29 - SagarAppProject] Success!
[2014-08-01 23:43:29 - SagarAppProject] Starting activity com.sagarappproject.MainActivity on device emulator-5554
[2014-08-01 23:43:32 - SagarAppProject] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.sagarappproject/.MainActivity }

After this i get a lot of log file errors 在此之后,我得到很多日志文件错误

08-01 16:30:22.400: D/AndroidRuntime(816): Shutting down VM
08-01 16:30:22.410: W/dalvikvm(816): threadid=1: thread exiting with uncaught exception (group=0xb2ae0d70)
08-01 16:30:22.420: E/AndroidRuntime(816): FATAL EXCEPTION: main
08-01 16:30:22.420: E/AndroidRuntime(816): Process: com.sagarappproject, PID: 816
08-01 16:30:22.420: E/AndroidRuntime(816): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sagarappproject/com.sagarappproject.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.os.Handler.dispatchMessage(Handler.java:102)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.os.Looper.loop(Looper.java:136)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.main(ActivityThread.java:5026)
08-01 16:30:22.420: E/AndroidRuntime(816):  at java.lang.reflect.Method.invokeNative(Native Method)
08-01 16:30:22.420: E/AndroidRuntime(816):  at java.lang.reflect.Method.invoke(Method.java:515)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
08-01 16:30:22.420: E/AndroidRuntime(816):  at dalvik.system.NativeStart.main(Native Method)
08-01 16:30:22.420: E/AndroidRuntime(816): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.Activity.setContentView(Activity.java:1930)
08-01 16:30:22.420: E/AndroidRuntime(816):  at   android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.sagarappproject.MainActivity.onCreate(MainActivity.java:13)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.Activity.performCreate(Activity.java:5242)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
08-01 16:30:22.420: E/AndroidRuntime(816):  ... 11 more

And this is my AndroidManifest.xml 这是我的AndroidManifest.xml

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="21" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
     </activity>
    </application>

    </manifest>

And this is my activity.xml 这是我的activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
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.sagarappproject.MainActivity" >

<TextView
    android:id="@+id/TextView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="32dp"
    android:layout_marginTop="32dp"
    android:text="@string/hello_world" />
</RelativeLayout>

It seems others have had the same problem. 似乎其他人也有同样的问题。 Change android:targetSdkVersion to 19 , as shown here 更改android:targetSdkVersion19 ,如图所示这里

See the answer here . 这里查看答案。

It states that 它指出

You cannot combine swipe dismissal and the action bar 您无法将滑动解除和操作栏结合在一起

as an sdk problem. 作为sdk问题。

The answer tells you to change the target sdk version to 19 答案告诉您将目标SDK版本更改为19

It also points out that 它还指出

Do not mess up with API Level and Platform, as Android Virtual Device. 不要搞乱API级别和平台(作为Android虚拟设备)。 With Level 19+ and Platform 4.2.2+ set on ADV everything runs as it should. 在ADV上设置了Level 19+和Platform 4.2.2+后,一切都会正常运行。

The problem is that your emulator uses 4.4W API wich is android Wear. 问题是您的模拟器使用4.4W API,而android Wear。 This means you cannot use the ActionBar on that emulator, becuase it uses the Wear framework. 这意味着您不能在该模拟器上使用ActionBar,因为它使用了Wear框架。 Try changing the emulator API level to 19 or 21. It should work then. 尝试将仿真器API级别更改为19或21。然后应该可以使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM