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

标签 android

我刚刚开始 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/

相关文章:

java - libcore.io.ErrnoException : open failed: ENOENT (No such file or directory)

java - 处理程序 postDelayed 只工作一次

java - SQLite 查询 - 一旦找到特定项目就停止从数据库返回行

android - 在包 'srcCompat' 中找不到属性 'learnapp.android.example.com.learnapp' 的资源标识符

java - 无法找到以下类错误(最新版本)

android - 确定移动设备是否在移动的飞机上?

android - Android TextView 的 autoLink ="all"功能

android - 如何在 RecyclerView 中精确显示十行

android - IBM Worklight - 应用程序在不同的 Android 操作系统版本中显示和行为不同

java - 从 Intent 中检索信息,然后将其设置到 Fragment 内的 TextView - Android