我是一个尝试使用eclipse学习Android应用程序开发的新手。我安装并遵循说明中的每一步。但是非常默认的项目(hello world)应用本身并没有运行。一些细节可能对我有用: -
Eclipse luna
android apk 4.4W
jdk 1.7.0_60
操作系统:win8.1 x64
错误: 模拟器只是说' appname'不幸的是关闭了 我发布了一些屏幕截图。如果你能帮助我,那就太好了。 注意:我没有对默认代码进行过一次更改。
的logcat:
07-05 05:47:33.202: D/dalvikvm(1748): Not late-enabling CheckJNI (already on)
07-05 05:47:33.362: D/AndroidRuntime(1748): Shutting down VM
07-05 05:47:33.362: W/dalvikvm(1748): threadid=1: thread exiting with uncaught exception (group=0xb3d38ce8)
07-05 05:47:33.372: E/AndroidRuntime(1748): FATAL EXCEPTION: main
07-05 05:47:33.372: E/AndroidRuntime(1748): Process: com.example.testapp2, PID: 1748
07-05 05:47:33.372: E/AndroidRuntime(1748): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testapp2/com.example.testapp2.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.os.Handler.dispatchMessage(Handler.java:102)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.os.Looper.loop(Looper.java:136)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.ActivityThread.main(ActivityThread.java:5026)
07-05 05:47:33.372: E/AndroidRuntime(1748): at java.lang.reflect.Method.invokeNative(Native Method)
07-05 05:47:33.372: E/AndroidRuntime(1748): at java.lang.reflect.Method.invoke(Method.java:515)
07-05 05:47:33.372: E/AndroidRuntime(1748): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-05 05:47:33.372: E/AndroidRuntime(1748): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-05 05:47:33.372: E/AndroidRuntime(1748): at dalvik.system.NativeStart.main(Native Method)
07-05 05:47:33.372: E/AndroidRuntime(1748): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-05 05:47:33.372: E/AndroidRuntime(1748): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-05 05:47:33.372: E/AndroidRuntime(1748): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-05 05:47:33.372: E/AndroidRuntime(1748): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-05 05:47:33.372: E/AndroidRuntime(1748): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.Activity.setContentView(Activity.java:1930)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
07-05 05:47:33.372: E/AndroidRuntime(1748): at com.example.testapp2.MainActivity.onCreate(MainActivity.java:13)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.Activity.performCreate(Activity.java:5242)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-05 05:47:33.372: E/AndroidRuntime(1748): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-05 05:47:33.372: E/AndroidRuntime(1748): ... 11 more
答案 0 :(得分:0)
是的,这是升级eclipse之后的问题。默认情况下它会创建由ActionBarActivity扩展的MainActivity。早期它被扩展到Activity.Many现在有额外的东西,比如Fragment和其他东西。虽然你是我的生活,但我不会这样做。我想混淆你,所以只需用下面的代码替换你的完整java代码。
package `Your Package Name`;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
答案 1 :(得分:0)
这是让你可以做的最简单的事情: 在项目树中:
MainActivity ..........{
替换为public class MainActivity extends Activity{