2010-11-16 123 views
4

我正在測試一個簡單的hello應用程序,它並未在仿真器上啓動。沒有錯誤,控制檯是這樣的:Android應用程序未在仿真器上啓動

[2010-11-16 21:26:06 - Hello World] ------------------------------ 
[2010-11-16 21:26:06 - Hello World] Android Launch! 
[2010-11-16 21:26:06 - Hello World] adb is running normally. 
[2010-11-16 21:26:06 - Hello World] Performing com.hello.HelloWorld.HelloWorld activity launch 
[2010-11-16 21:26:09 - Hello World] Launching a new emulator with Virtual Device 'VirtualDevice2.2'  

模擬器啓動,屏幕出現鎖定,我的應用程序無法啓動。
試圖解鎖,並去發射器尋找我的應用程序,它不存在。
任何人都可以幫助我解決這個問題嗎?
謝謝。

代碼:


package com.hello.HelloWorld; 

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

public class HelloWorld extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle icicle) { 
     super.onCreate(icicle); 
     // We want to view some very simple text, so we need a TextView 
     TextView tv = new TextView(this); 
     // Put some text to the newly created TextVIew 
     tv.setText("Hello Android"); 
     // Tell our App to display the textView 
     this.setContentView(tv); 
    } 
} 

清單:

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

</manifest> 
+0

聽起來像一個明顯的問題。介意發佈它? – phobos51594 2010-11-16 22:04:25

+0

<?xml version =「1.0」encoding =「utf-8」?> JEagle 2010-11-16 22:12:51

+0

您可以在發佈問題時按ctrl + k來標記清單(當然包括任何xml),以避免顯示空白。 – 2010-11-16 22:27:23

回答

2

我會想你是在Windows 7或Vista的開發。無論哪種情況,您的主機文件都將「localhost」映射到「:: 1」。 Android(截至2.2)不能很好地處理IPv6,所以你會在日誌中找到一個「協議綁定」失敗(不是logcat的東西,DDMS IIRC)。

要解決此問題,您需要將localhost的定義更改爲「127.0.0.1」。 C:\ WINDOWS \ SYSTEM32 \ DRIVERS \ ETC \主機。將「:: 1」更改爲「127.0.0.1」。 IIRC,您必須將A保存爲不同的名稱,刪除原始內容,然後重新命名爲「主機」,但不能包含擴展名。


或者你可以使用沒有他們自己種植的USB驅動程序的HTC設備。查看HTC針對您的操作系統的「HTC Synch」應用程序支持頁面。

+0

使用Vista。沒有改變,但仍然是一樣的。我需要重新啓動嗎? – JEagle 2010-11-16 22:23:23

+0

好的。只是做了一次重啓,它的工作!謝謝。 – JEagle 2010-11-16 22:50:03

相關問題