Android 应用程序总是崩溃 [英] Android app always crashing

查看:40
本文介绍了Android 应用程序总是崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 android 编程新手,所以我开始关注互联网上的教程,非常简单的东西,但是当我编译它以便在模拟器上运行时,它总是说:不幸的是,你的程序已停止" on我的设备模拟器(nexus 4)所以我认为我的 java 代码有错误.

I'm new at programming for android so i've started to follow tutorials on the internet, very simple stuff but when I compiled it in order to run on the emulator it always says: "Unfortunately your program has stopped" on my device emulator (nexus 4) so i thought I had an error on my java code.

所以我创建了一个全新的项目,没有使用通常的hello world"进行修改,所以它应该可以工作,但是当我要运行它时,它看起来是一样的.不幸的是,您的程序已停止".这是我的控制台上显示的内容.

So I created a brand new project unmodified with the usual "hello world" so it should work, but when I'm going to run it appears the same thing. "Unfortunately your program has stopped". Here's what shows on my console.

可能与我使用的 API 版本有关?

Maybe it has something to do with the version of the API i'm using?

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

清单文件更新:

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MyActivity"
            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>

推荐答案

使用 targetSdkVersion 为 19.

Use targetSdkVersion as 19.

<uses-sdk
    android:minSdkVersion="15"
    android:targetSdkVersion="19" />

API 20 有问题

参考

希望对你有帮助.

这篇关于Android 应用程序总是崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆