健康食谱已停止工作

时间:2014-09-07 02:57:36

标签: java android eclipse

我在eclipse Juno(Windows 8.1)中有一个完整的Android应用程序,当我尝试在nexus one模拟器上运行它时,我的目标API在20崩溃。对于我的项目,最小API设置为14,我的窗口中显示零错误。

我确实得到了这个文本“等待主页('android.process.acore')启动...”在模拟器上的安卓屏幕消失后,随时间出现背景。

我已经使用Android Boot Camp一书作为参考,并遵循AVD设置的字母。

这是我的mainactivity.java代码,Recipe.java代码跟随它。崩溃后的logcat错误列表

package net.androidbootcamp.healthyrecipes;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button b = (Button) findViewById(R.id.btnRecipe);
    b.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent(MainActivity.this, Recipe.class));
        }
    });
}


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


package net.androidbootcamp.healthyrecipes;

import android.app.Activity;
import android.os.Bundle;

public class Recipe extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recipe);
    }
}
09-07 03:18:01.230: E/AndroidRuntime(665): FATAL EXCEPTION: main
09-07 03:18:01.230: E/AndroidRuntime(665): Process: net.androidbootcamp.healthyrecipes, PID: 665
09-07 03:18:01.230: E/AndroidRuntime(665): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.androidbootcamp.healthyrecipes/net.androidbootcamp.healthyrecipes.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.os.Handler.dispatchMessage(Handler.java:102)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.os.Looper.loop(Looper.java:136)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.ActivityThread.main(ActivityThread.java:5026)
09-07 03:18:01.230: E/AndroidRuntime(665):  at java.lang.reflect.Method.invokeNative(Native Method)
09-07 03:18:01.230: E/AndroidRuntime(665):  at java.lang.reflect.Method.invoke(Method.java:515)
09-07 03:18:01.230: E/AndroidRuntime(665):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
09-07 03:18:01.230: E/AndroidRuntime(665):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
09-07 03:18:01.230: E/AndroidRuntime(665):  at dalvik.system.NativeStart.main(Native Method)
09-07 03:18:01.230: E/AndroidRuntime(665): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
09-07 03:18:01.230: E/AndroidRuntime(665):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
09-07 03:18:01.230: E/AndroidRuntime(665):  at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
09-07 03:18:01.230: E/AndroidRuntime(665):  at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
09-07 03:18:01.230: E/AndroidRuntime(665):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.Activity.setContentView(Activity.java:1930)
09-07 03:18:01.230: E/AndroidRuntime(665):  at net.androidbootcamp.healthyrecipes.MainActivity.onCreate(MainActivity.java:17)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.Activity.performCreate(Activity.java:5242)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-07 03:18:01.230: E/AndroidRuntime(665):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
09-07 03:18:01.230: E/AndroidRuntime(665):  ... 11 more

1 个答案:

答案 0 :(得分:0)

请勿将API等级20和平台4.4W(Android Wear SDK)定位为Android虚拟设备。

使用API​​级别19,一切都应该正常。

在您的清单(AndroidManifest.xml)

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