2014-07-13 152 views
0

我正在試圖用我的手在android開發中從C++中獲得一絲空氣。我下載了預先打包的eclipse和android IDE。我按照教程,並運行Android應用程序,但在模擬器上,它總是說「不幸的是,已停止工作」,因爲它正在加載。我查了一堆解決方案,都沒有工作。Android教程應用程序無法正常工作

這是明顯的xml文件:

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

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

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

,這是主要的XML文件:

<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="no.luck.stillnoluck.MainActivity" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/hello_world" /> 

</RelativeLayout> 

,這是主要的Java文件:

package no.luck.stillnoluck; 

import android.support.v7.app.ActionBarActivity; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.MenuItem; 

public class MainActivity extends ActionBarActivity { 

    @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); 
    } 
} 

這裏是logcat文件:

07-13 15:44:58.890: D/AndroidRuntime(898): Shutting down VM 
07-13 15:44:58.890: W/dalvikvm(898): threadid=1: thread exiting with uncaught   exception (group=0xb3a8ed70) 
07-13 15:44:58.920: E/AndroidRuntime(898): FATAL EXCEPTION: main 
07-13 15:44:58.920: E/AndroidRuntime(898): Process: no.luck.stillnoluck, PID: 898 
07-13 15:44:58.920: E/AndroidRuntime(898): java.lang.RuntimeException: Unable to startactivity ComponentInfo{no.luck.stillnoluck/no.luck.stillnoluck.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 
07-13 15:44:58.920: E/AndroidRuntime(898): at        android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.app.ActivityThread.access$800(ActivityThread.java:138) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.os.Handler.dispatchMessage(Handler.java:102) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.os.Looper.loop(Looper.java:136) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.app.ActivityThread.main(ActivityThread.java:5026) 
07-13 15:44:58.920: E/AndroidRuntime(898): at java.lang.reflect.Method.invokeNative(Native Method) 
07-13 15:44:58.920: E/AndroidRuntime(898): at java.lang.reflect.Method.invoke(Method.java:515) 
07-13 15:44:58.920: E/AndroidRuntime(898): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 
07-13 15:44:58.920: E/AndroidRuntime(898): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 
07-13 15:44:58.920: E/AndroidRuntime(898): at dalvik.system.NativeStart.main(Native Method) 
07-13 15:44:58.920: E/AndroidRuntime(898): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 
07-13 15:44:58.920: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275) 
07-13 15:44:58.920: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872) 
07-13 15:44:58.920: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129) 
07-13 15:44:58.920: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.app.Activity.setContentView(Activity.java:1930) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77) 
07-13 15:44:58.920: E/AndroidRuntime(898): at no.luck.stillnoluck.MainActivity.onCreate(MainActivity.java:13) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.app.Activity.performCreate(Activity.java:5242) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
07-13 15:44:58.920: E/AndroidRuntime(898): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161) 
07-13 15:44:58.920: E/AndroidRuntime(898): ... 11 more 
07-13 15:45:44.460: I/Process(898): Sending signal. PID: 898 SIG: 9 
07-13 15:54:11.660: D/AndroidRuntime(936): Shutting down VM 
07-13 15:54:11.660: W/dalvikvm(936): threadid=1: thread exiting with uncaught exception (group=0xb3a8ed70) 
07-13 15:54:11.690: E/AndroidRuntime(936): FATAL EXCEPTION: main 
07-13 15:54:11.690: E/AndroidRuntime(936): Process: no.luck.stillnoluck, PID: 936 
07-13 15:54:11.690: E/AndroidRuntime(936): java.lang.RuntimeException: Unable to start activity ComponentInfo{no.luck.stillnoluck/no.luck.stillnoluck.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.ActivityThread.access$800(ActivityThread.java:138) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.os.Handler.dispatchMessage(Handler.java:102) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.os.Looper.loop(Looper.java:136) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.ActivityThread.main(ActivityThread.java:5026) 
07-13 15:54:11.690: E/AndroidRuntime(936): at java.lang.reflect.Method.invokeNative(Native Method) 
07-13 15:54:11.690: E/AndroidRuntime(936): at java.lang.reflect.Method.invoke(Method.java:515) 
07-13 15:54:11.690: E/AndroidRuntime(936): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 
07-13 15:54:11.690: E/AndroidRuntime(936): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 
07-13 15:54:11.690: E/AndroidRuntime(936): at dalvik.system.NativeStart.main(Native Method) 
07-13 15:54:11.690: E/AndroidRuntime(936): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 
07-13 15:54:11.690: E/AndroidRuntime(936): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275) 
07-13 15:54:11.690: E/AndroidRuntime(936): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872) 
07-13 15:54:11.690: E/AndroidRuntime(936): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129) 
07-13 15:54:11.690: E/AndroidRuntime(936): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.Activity.setContentView(Activity.java:1930) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77) 
07-13 15:54:11.690: E/AndroidRuntime(936): at no.luck.stillnoluck.MainActivity.onCreate(MainActivity.java:13) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.Activity.performCreate(Activity.java:5242) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
07-13 15:54:11.690: E/AndroidRuntime(936): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161) 
07-13 15:54:11.690: E/AndroidRuntime(936): ... 11 more 
07-13 15:54:41.400: I/Process(936): Sending signal. PID: 936 SIG: 9 
07-13 15:55:08.450: D/AndroidRuntime(972): Shutting down VM 
07-13 15:55:08.460: W/dalvikvm(972): threadid=1: thread exiting with uncaught exception (group=0xb3a8ed70) 
07-13 15:55:08.480: E/AndroidRuntime(972): FATAL EXCEPTION: main 
07-13 15:55:08.480: E/AndroidRuntime(972): Process: no.luck.stillnoluck, PID: 972 
07-13 15:55:08.480: E/AndroidRuntime(972): java.lang.RuntimeException: Unable to start activity ComponentInfo{no.luck.stillnoluck/no.luck.stillnoluck.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.ActivityThread.access$800(ActivityThread.java:138) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.os.Handler.dispatchMessage(Handler.java:102) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.os.Looper.loop(Looper.java:136) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.ActivityThread.main(ActivityThread.java:5026) 
07-13 15:55:08.480: E/AndroidRuntime(972): at java.lang.reflect.Method.invokeNative(Native Method) 
07-13 15:55:08.480: E/AndroidRuntime(972): at java.lang.reflect.Method.invoke(Method.java:515) 
07-13 15:55:08.480: E/AndroidRuntime(972): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 
07-13 15:55:08.480: E/AndroidRuntime(972): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602) 
07-13 15:55:08.480: E/AndroidRuntime(972): at dalvik.system.NativeStart.main(Native Method) 
07-13 15:55:08.480: E/AndroidRuntime(972): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar. 
07-13 15:55:08.480: E/AndroidRuntime(972): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275) 
07-13 15:55:08.480: E/AndroidRuntime(972): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872) 
07-13 15:55:08.480: E/AndroidRuntime(972): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129) 
07-13 15:55:08.480: E/AndroidRuntime(972): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.Activity.setContentView(Activity.java:1930) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77) 
07-13 15:55:08.480: E/AndroidRuntime(972): at no.luck.stillnoluck.MainActivity.onCreate(MainActivity.java:13) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.Activity.performCreate(Activity.java:5242) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
07-13 15:55:08.480: E/AndroidRuntime(972): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161) 
07-13 15:55:08.480: E/AndroidRuntime(972): ... 11 more 
07-13 15:55:46.190: I/Process(972): Sending signal. PID: 972 SIG: 9 

回答

1

嘗試使用

android:targetSdkVersion="19" 

代替

android:targetSdkVersion="20" 

不要使用API Level of 20 and Platform 4.4W,作爲Android虛擬設備。在ADV上設置Level 19和Platform 4.2.2時,所有操作都應該如此。

注意:更改清潔您的項目後。 Here是一個類似的問題。

+0

就是這樣,謝謝!我一直在圍繞這個IDE踢我笨拙的腳幾個小時試圖找出它。 – ExpletiveDeleted

+0

@ExpletiveDeleted樂於幫助,享受編碼。 –

相關問題