gpt4 book ai didi

android - 你好android教程错误: request time failed

转载 作者:太空狗 更新时间:2023-10-29 15:24:30 24 4
gpt4 key购买 nike

我刚刚开始 Android 开发并试用 HelloAndroid 教程。我已经被困了几天了。最初,我第一次尝试时,一切正常,然后我继续第二个教程,一切都坏了。所以我试图回到最简单和原始的教程并弄清楚发生了什么。

我编辑了三个主要文件:HelloAndroid2.java包 com.example.HelloAndroid2;

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

public class HelloAndroid2 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

主.xml:

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

字符串.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloAndroid2!</string>
<string name="app_name">HelloAndroid2</string>
</resources>

这些都是教程中的内容。

When I run it, the console output is:
[2010-07-06 16:37:16 - HelloAndroid2] ------------------------------
[2010-07-06 16:37:16 - HelloAndroid2] Android Launch!
[2010-07-06 16:37:16 - HelloAndroid2] adb is running normally.
[2010-07-06 16:37:16 - HelloAndroid2] Performing com.example.HelloAndroid2.HelloAndroid2 activity launch
[2010-07-06 16:37:16 - HelloAndroid2] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'HelloWorld'
[2010-07-06 16:37:16 - HelloAndroid2] WARNING: Application does not specify an API level requirement!
[2010-07-06 16:37:16 - HelloAndroid2] Device API version is 8 (Android 2.2)
[2010-07-06 16:37:16 - HelloAndroid2] Uploading HelloAndroid2.apk onto device 'emulator-5554'
[2010-07-06 16:37:16 - HelloAndroid2] Installing HelloAndroid2.apk...
[2010-07-06 16:37:22 - HelloAndroid2] Success!
[2010-07-06 16:37:22 - HelloAndroid2] Starting activity com.example.HelloAndroid2.HelloAndroid2 on device
[2010-07-06 16:37:26 - HelloAndroid2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.HelloAndroid2/.HelloAndroid2 }

因此,它只是卡在了开头: Intent ...模拟器会显示时间、日期和正在充电的事实。我正在开发 Android 2.2。我尝试从 LogCat 中获取一些数据,这些是最后几行:

07-06 20:37:25.935: INFO/AndroidRuntime(387): NOTE: attach of thread 'Binder Thread #3' failed
07-06 20:37:27.265: INFO/ActivityManager(65): Displayed activity com.example.HelloAndroid2/.HelloAndroid2: 1461 ms (total 1461 ms)
07-06 20:37:32.376: DEBUG/dalvikvm(114): GC_EXPLICIT freed 562 objects / 31672 bytes in 95ms
07-06 20:37:37.386: DEBUG/dalvikvm(197): GC_EXPLICIT freed 82 objects / 7592 bytes in 87ms
07-06 20:37:42.386: DEBUG/dalvikvm(250): GC_EXPLICIT freed 26 objects / 1120 bytes in 102ms
07-06 20:38:10.437: DEBUG/SntpClient(65): request time failed: java.net.SocketException: Address family not supported by protocol

所以基本上,模拟器上什么也没有发生,它应该说 HelloAndroid 或类似的东西。请帮忙。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.HelloAndroid2"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloAndroid2"
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>

最佳答案

WARNING: Application does not specify an API level requirement!

在你的 manifest.xml 文件中定义 android:minSdkVersion

   </application>

<uses-sdk android:minSdkVersion="3" />

</manifest>

关于android - 你好android教程错误: request time failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3190097/

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