gpt4 book ai didi

android - "Hello World"Android 应用程序出现问题

转载 作者:行者123 更新时间:2023-11-30 02:46:01 26 4
gpt4 key购买 nike

无法弄清楚这个应用程序出了什么问题。在整个互联网上寻找,过去 3 天一直在尝试解决这个问题,一直在寻找整个互联网。控制台的最后两行如下所示:

[2014-07-29 01:46:01 - HelloWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.helloworld/.MainActivity }
[2014-07-29 01:46:01 - HelloWorld] ActivityManager: Warning: Activity not started, its current task has been brought to the front

这是Java:

package com.example.helloworld;

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


public class MainActivity extends ActionBarActivity {

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

@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);
}
public void button_touch(View v)
{
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText("Hello, world.");

}
}

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="com.example.helloworld.MainActivity" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="143dp"
android:textAppearance="?android:attr/textAppearanceMedium" />

<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="67dp"
android:onClick="button_touch"
android:text="Say hi" />


</RelativeLayout>

这里是控制台的更多内容:

{[2014-07-29 01:45:50 - HelloWorld] ------------------------------
[2014-07-29 01:45:50 - HelloWorld] Android Launch!
[2014-07-29 01:45:50 - HelloWorld] adb is running normally.
[2014-07-29 01:45:50 - HelloWorld] Performing com.example.helloworld.MainActivity activity launch
[2014-07-29 01:45:50 - HelloWorld] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Level20'
[2014-07-29 01:45:52 - HelloWorld] ------------------------------
[2014-07-29 01:45:52 - HelloWorld] Android Launch!
[2014-07-29 01:45:52 - HelloWorld] adb is running normally.
[2014-07-29 01:45:52 - HelloWorld] Performing com.example.helloworld.MainActivity activity launch
[2014-07-29 01:45:53 - HelloWorld] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'Level20'
[2014-07-29 01:45:54 - HelloWorld] Application already deployed. No need to reinstall.
[2014-07-29 01:45:54 - HelloWorld] Starting activity com.example.helloworld.MainActivity on device emulator-5554
[2014-07-29 01:45:56 - HelloWorld] ActivityManager: WARNING: linker: libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
[2014-07-29 01:45:59 - HelloWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.helloworld/.MainActivity }
[2014-07-29 01:45:59 - HelloWorld] Application already deployed. No need to reinstall.
[2014-07-29 01:45:59 - HelloWorld] Starting activity com.example.helloworld.MainActivity on device emulator-5554
[2014-07-29 01:45:59 - HelloWorld] ActivityManager: WARNING: linker: libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
[2014-07-29 01:46:01 - HelloWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.helloworld/.MainActivity }
[2014-07-29 01:46:01 - HelloWorld] ActivityManager: Warning: Activity not started, its current task has been brought to the front
}

这是日志:

07-29 06:49:01.152: I/Process(1711): Sending signal. PID: 1711 SIG: 9
07-29 06:49:02.522: D/AndroidRuntime(1770): Shutting down VM
07-29 06:49:02.522: W/dalvikvm(1770): threadid=1: thread exiting with uncaught exception (group=0xb0d3bce8)
07-29 06:49:02.532: E/AndroidRuntime(1770): FATAL EXCEPTION: main
07-29 06:49:02.532: E/AndroidRuntime(1770): Process: com.example.helloworld, PID: 1770
07-29 06:49:02.532: E/AndroidRuntime(1770): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloworld/com.example.helloworld.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.os.Handler.dispatchMessage(Handler.java:102)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.os.Looper.loop(Looper.java:136)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.ActivityThread.main(ActivityThread.java:5026)
07-29 06:49:02.532: E/AndroidRuntime(1770): at java.lang.reflect.Method.invokeNative(Native Method)
07-29 06:49:02.532: E/AndroidRuntime(1770): at java.lang.reflect.Method.invoke(Method.java:515)
07-29 06:49:02.532: E/AndroidRuntime(1770): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-29 06:49:02.532: E/AndroidRuntime(1770): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-29 06:49:02.532: E/AndroidRuntime(1770): at dalvik.system.NativeStart.main(Native Method)
07-29 06:49:02.532: E/AndroidRuntime(1770): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-29 06:49:02.532: E/AndroidRuntime(1770): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-29 06:49:02.532: E/AndroidRuntime(1770): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-29 06:49:02.532: E/AndroidRuntime(1770): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-29 06:49:02.532: E/AndroidRuntime(1770): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.Activity.setContentView(Activity.java:1930)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
07-29 06:49:02.532: E/AndroidRuntime(1770): at com.example.helloworld.MainActivity.onCreate(MainActivity.java:16)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.Activity.performCreate(Activity.java:5242)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-29 06:49:02.532: E/AndroidRuntime(1770): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-29 06:49:02.532: E/AndroidRuntime(1770): ... 11 more

list xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.support.v7.appcompat">
<uses-sdk android:minSdkVersion="7"/>
<application />
</manifest>

最佳答案

将您的应用定位到版本 19 而不是 20,并在 19 模拟器而不是 20 上运行

关于android - "Hello World"Android 应用程序出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25009969/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com