run application出现Unfortunately, HelloWorld has stopped

zw520lbzw520lb 2016-03-27 12:08:40
我是新手,自己弄了个adt bundle,打算捣鼓捣鼓,不过有个问题解决不了

我的步骤是这样的,
1.新建了一个avd,然后start,
2.运行我的程序,右键--run as --android application

然后就报Unfortunately, HelloWorld has stopped

附上我的程序源码以及错误信息

main.java

package com.example.helloworld;

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


public class Main extends Activity {

private Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

button =(Button)this.findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(Main.this,OtherActivity.class);
OtherActivity.name="jack";
OtherActivity.age=13;
startActivity(intent);
}
});

}
}


OtherActivity.java
package com.example.helloworld;

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

public class OtherActivity extends Activity {

private TextView textView;
public static String name;
public static int age;

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.other);
textView = (TextView)this.findViewById(R.id.msg);
textView.setText("-name->>"+name+"\n"+"-age-->>"+age);


}
}


main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button android:id="@+id/button" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="使用静态变量传递数据" />

</LinearLayout>



other.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/msg" android:layout_width="fill_parent"
android:layout_height="fill_parent" />"

</LinearLayout>


AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloworld"
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=".Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".OtherActivity">

</activity>

</application>

</manifest>


LogCat里面的信息


03-27 04:10:32.950: D/dalvikvm(653): Not late-enabling CheckJNI (already on)
03-27 04:10:33.710: D/AndroidRuntime(653): Shutting down VM
03-27 04:10:33.710: W/dalvikvm(653): threadid=1: thread exiting with uncaught exception (group=0xb4a17d70)
03-27 04:10:33.740: E/AndroidRuntime(653): FATAL EXCEPTION: main
03-27 04:10:33.740: E/AndroidRuntime(653): Process: com.example.helloworld, PID: 653
03-27 04:10:33.740: E/AndroidRuntime(653): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloworld/com.example.helloworld.Main}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.access$800(ActivityThread.java:138)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.os.Handler.dispatchMessage(Handler.java:102)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.os.Looper.loop(Looper.java:136)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.main(ActivityThread.java:5026)
03-27 04:10:33.740: E/AndroidRuntime(653): at java.lang.reflect.Method.invokeNative(Native Method)
03-27 04:10:33.740: E/AndroidRuntime(653): at java.lang.reflect.Method.invoke(Method.java:515)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
03-27 04:10:33.740: E/AndroidRuntime(653): at dalvik.system.NativeStart.main(Native Method)
03-27 04:10:33.740: E/AndroidRuntime(653): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.Activity.setContentView(Activity.java:1930)
03-27 04:10:33.740: E/AndroidRuntime(653): at com.example.helloworld.Main.onCreate(Main.java:17)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.Activity.performCreate(Activity.java:5242)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-27 04:10:33.740: E/AndroidRuntime(653): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
03-27 04:10:33.740: E/AndroidRuntime(653): ... 11 more
03-27 04:15:34.060: I/Process(653): Sending signal. PID: 653 SIG: 9
...全文
460 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wannatop 2017-03-08
  • 打赏
  • 举报
回复
解决没有?我刚学android,按书做建一个空的helloworld工程都运行不了,就是你这种问题。
zw520lbzw520lb 2016-03-28
  • 打赏
  • 举报
回复
没有人吗??????????
zw520lbzw520lb 2016-03-27
  • 打赏
  • 举报
回复
补充一句,我直接创建个helloworld,也是同样的问题,好像问题不在程序

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧