helloandroid教程错误:请求时失败错误、教程、helloandroid

2023-09-04 12:50:02 作者:男人毁在右手上。

我刚开始在Android上开发和尝试的HelloAndroid教程。我一直在坚持了几天了。最初,我第一次尝试它,一切完美的作品,然后我继续前进的第二个教程一切都打破了。所以我想回到最简单,最原始的教程,并找出发生了什么。

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

 进口android.app.Activity;
进口android.os.Bundle;

公共类HelloAndroid2延伸活动{
    / **第一次创建活动时调用。 * /
    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);
    }
}
 

main.xml中:

 < XML版本=1.0编码=UTF-8&GT?;
< TextView中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
  机器人:ID =@ + ID / TextView的
  机器人:layout_width =FILL_PARENT
  机器人:layout_height =FILL_PARENT
  机器人:文本=@字符串/你好/>
 
android反编译工具

strings.xml中:

 < XML版本=1.0编码=UTF-8&GT?;
<资源>
    <字符串名称=你好>的Hello World,HelloAndroid2<!/串>
    <字符串名称=APP_NAME> HelloAndroid2< /串>
< /资源>
 

这些都是从教程。

 当我运行它,在控制台输出为:
[2010-07-06 16时37分16秒 -  HelloAndroid2] ------------------------------
[2010-07-06 16时37分16秒 -  HelloAndroid2] Android的推出!
[2010-07-06 16时37分16秒 -  HelloAndroid2]亚洲开发银行运行正常。
[2010-07-06 16时37分16秒 -  HelloAndroid2]执行com.example.HelloAndroid2.HelloAndroid2活动启动
[2010-07-06 16时37分16秒 -  HelloAndroid2]目标自动模式:利用现有的模拟器模拟器-5554'运行兼容AVD的HelloWorld
[2010-07-06 16时37分16秒 -  HelloAndroid2]警告:应用程序没有指定的API等级要求!
[2010-07-06 16时37分16秒 -  HelloAndroid2]设备API版本8(Android 2.2的)
[2010-07-06 16时37分16秒 -  HelloAndroid2]上传HelloAndroid2.apk到器件的模拟器,5554
[2010-07-06 16时37分16秒 -  HelloAndroid2]安装HelloAndroid2.apk ...
[2010-07-06 16点37分22秒 -  HelloAndroid2]成功!
[2010-07-06 16点37分22秒 -  HelloAndroid2]启动活动com.example.HelloAndroid2.HelloAndroid2的设备
[2010-07-06十六时37分26秒 -  HelloAndroid2] ActivityManager:开始:意向{行为= android.intent.action.MAIN猫= [android.intent.category.LAUNCHER] CMP = com.example.HelloAndroid2 / .HelloAndroid2 }
 

所以,它只是卡在起跑线:意图... 仿真器显示与时间,日期,并且它充电的fac。我正在开发在Android 2.2。 我试图得到一些数据出来LogCat中的,这些都是过去的几行:

  07-06 20:37:25.935:信息/ AndroidRuntime(387):注:连接线的捆扎线#3'失败
07-06 20:37:27.265:信息/ ActivityManager(65):显示活动com.example.HelloAndroid2 / .HelloAndroid2:1461毫秒(共1461毫秒)
07-06 20:37:32.376:DEBUG / dalvikvm(114):GC_EXPLICIT释放562对象/ 31672字节95MS
07-06 20:37:37.386:DEBUG / dalvikvm(197):GC_EXPLICIT释放82的对象/ 7592字节的87ms
07-06 20:37:42.386:调试/ dalvikvm(250):GC_EXPLICIT释放26的对象/ 1120字节在102ms
07-06 20:38:10.437:DEBUG / SntpClient(65):请求时失败:产生java.net.SocketException:地址族不支持的协议
 

因此​​,基本上,没有发生在模拟器上,它应该说HelloAndroid或者类似的东西。请大家帮帮忙。

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
      包=com.example.HelloAndroid2
      安卓版code =1
      机器人:VERSIONNAME =1.0>
    <应用机器人:图标=@可绘制/图标机器人:标签=@字符串/ APP_NAME>
        <活动机器人:名称=。HelloAndroid2
                  机器人:标签=@字符串/ APP_NAME>
            <意向滤光器>
                <作用机器人:名称=android.intent.action.MAIN/>
                <类机器人:名称=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;

    < /用途>


< /舱单>
 

解决方案

那么,为什么不开始时简单,并创建一个新的AVD,同时指定分钟。 SDK的,所以它会在那里。

然后运行该AVD足够可靠,确保没有Android应用程序正在运行,然后从Eclipse的运行运行配置...目标手册<!!!!润> 推出新的Andr​​oid虚拟设备[然后单击到窗格的行项目强调的是AVD] <!OK>

等待事情来加载(等待ActivityManager:开始:意图在Eclipse控制台反馈线)。然后preSS <菜单> 对皮肤

如果说AVD已经运行,并要再次运行它,改变线在Java code,然后运行运行配置...目标自动<!!!!应用&GT ;! <润GT;

I am just starting out on android development and trying out the HelloAndroid tutorial. I have been stuck for a few days now. Initially, the first time I tried it, everything works perfectly and then I move on the second tutorial everything broke. So I'm trying to go back to the easiest and original tutorial and figure out what is happening.

There are three main file that I edited: HelloAndroid2.java package 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);
    }
}

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"/>

strings.xml:

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

These are all from the tutorial.

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 }

So, it just gets stuck at the starting: intent... The emulator shows up with the time, date, and the fac that it is charging. I'm developing on Android 2.2. I try to get some data out of LogCat and these are the last few lines:

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

So basically, nothing happen on the emulator and it should say HelloAndroid or something like that. Please help.

<?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> 

解决方案

So why not start out simple, and create a new AVD while specifying a min. SDK for it, so it'll be there.

Then to run that AVD reliably enough, make sure no Android apps are running, then from Eclipse Run!Run Configurations...!Target!Manual!<Run>!Launch a new Android Virtual Device![then click onto the pane's line item to highlight that AVD]!<OK>.

Wait for the thing to load (wait for the "ActivityManager: Starting: Intent" line on your Eclipse Console feedback). Then press <Menu> on the skin.

If that AVD is already running and you want to run it again, change a line in your Java code, then Run!Run Configurations...!Target!Automatic!<Apply>!<Run>.