Android app always crashing

邮差的信 提交于 2019-12-02 19:17:10

问题


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.

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.

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

Manifest file update:

<?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>

回答1:


Use targetSdkVersion as 19.

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

There is a problem with API 20

Reference

Hope it helps.




回答2:


You will have to set the correct target and minsdkversion like this:

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



回答3:


Change your manifest like this;

<?xml version="1.0" encoding="utf-8"?>

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

<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>



来源:https://stackoverflow.com/questions/24573477/android-app-always-crashing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!