5

我目前在 Eclipse Indigo Service Release 2 上运行 android 模拟器(Android 1.6 api level 4)版本 18,在 Debian 6.0 上使用 ADT 插件 18.0。我在代理地址的大学代理(鱿鱼)后面:http://172.20.0.99:8080没有身份验证。它是一个 eth0 连接,所以没有无线/局域网卡问题。我在环境变量和模拟器选项中都设置了代理。也正如之前的一些帖子中提到的,我提供了 -dns-server 选项。我的模拟器运行如下。

./emulator -avd "Android1_6" -dns-server "8.8.8.8" -http-proxy http://172.20.0.99:8080 -verbose
emulator: found SDK root at /opt/android-sdk-linux
emulator: Android virtual device file at: /home/dheeraj/.android/avd/Android1_6.ini
emulator: virtual device content at /home/dheeraj/.android/avd/Android1_6.avd
emulator: virtual device config file: /home/dheeraj/.android/avd/Android1_6.avd/config.ini
emulator: using core hw config path: /home/dheeraj/.android/avd/Android1_6.avd/hardware-qemu.ini
emulator: Found AVD target API level: 4
emulator: found skin 'WVGA800' in directory: /opt/android-sdk-linux/platforms/android-4/skins
emulator: autoconfig: -skin WVGA800
emulator: autoconfig: -skindir /opt/android-sdk-linux/platforms/android-4/skins
emulator: keyset loaded from: /home/dheeraj/.android/default.keyset
emulator: trying to load skin file '/opt/android-sdk-linux/platforms/android-4/skins/WVGA800/layout'
emulator: skin network speed: 'full'
emulator: skin network delay: 'none'
emulator: autoconfig: -kernel /opt/android-sdk-linux/platforms/android-4/images//kernel-qemu
emulator: autoconfig: -ramdisk /opt/android-sdk-linux/platforms/android-4/images//ramdisk.img
emulator: Using initial system image: /opt/android-sdk-linux/platforms/android-4/images//system.img
emulator: autoconfig: -data /home/dheeraj/.android/avd/Android1_6.avd/userdata-qemu.img
emulator: autoconfig: -initdata /home/dheeraj/.android/avd/Android1_6.avd/userdata.img
emulator: autoconfig: -cache /home/dheeraj/.android/avd/Android1_6.avd/cache.img
emulator: autoconfig: -sdcard /home/dheeraj/.android/avd/Android1_6.avd/sdcard.img
emulator: Physical RAM size: 128MB

Content of hardware configuration file:
  hw.cpu.arch = arm
  hw.ramSize = 128
  hw.touchScreen = yes
  hw.multiTouch = no
  hw.mainKeys = yes
  hw.trackBall = yes
  hw.keyboard = yes
  hw.keyboard.lid = yes
  hw.keyboard.charmap = qwerty2
  hw.dPad = yes
  hw.gsmModem = yes
  hw.camera = yes
  hw.camera.maxHorizontalPixels = 640
  hw.camera.maxVerticalPixels = 480
  hw.gps = yes
  hw.battery = yes
  hw.accelerometer = yes
  hw.audioInput = yes
  hw.audioOutput = yes
  hw.sdCard = yes
  hw.sdCard.path = /home/dheeraj/.android/avd/Android1_6.avd/sdcard.img
  disk.cachePartition = yes
  disk.cachePartition.path = /home/dheeraj/.android/avd/Android1_6.avd/cache.img
  disk.cachePartition.size = 66m
  hw.lcd.width = 480
  hw.lcd.height = 800
  hw.lcd.depth = 16
  hw.lcd.density = 240
  hw.lcd.backlight = yes
  hw.gpu.enabled = no
  hw.fakeCamera = back
  hw.webcam.count = 6
  hw.webcam.0.name = webcam0
  hw.webcam.1.name = webcam1
  hw.webcam.2.name = webcam2
  hw.webcam.3.name = webcam3
  hw.webcam.4.name = webcam4
  hw.webcam.5.name = webcam5
  hw.webcam.0.direction = front
  hw.webcam.1.direction = back
  hw.webcam.2.direction = front
  hw.webcam.3.direction = front
  hw.webcam.4.direction = front
  hw.webcam.5.direction = front
  vm.heapSize = 24
  hw.sensors.proximity = yes
  hw.sensors.magnetic_field = yes
  hw.sensors.orientation = yes
  hw.sensors.temperature = yes
  kernel.path = /opt/android-sdk-linux/platforms/android-4/images//kernel-qemu
  kernel.parameters =  android.checkjni=1
  disk.ramdisk.path = /opt/android-sdk-linux/platforms/android-4/images//ramdisk.img
  disk.systemPartition.initPath = /opt/android-sdk-linux/platforms/android-4/images//system.img
  disk.systemPartition.size = 128m
  disk.dataPartition.path = /home/dheeraj/.android/avd/Android1_6.avd/userdata-qemu.img
  disk.dataPartition.size = 128m
  avd.name = Android1_6
.
QEMU options list:
emulator: argv[00] = "./emulator-arm"
emulator: argv[01] = "-dns-server"
emulator: argv[02] = "8.8.8.8"
emulator: argv[03] = "-http-proxy"
emulator: argv[04] = "http://172.20.0.99:8080"
emulator: argv[05] = "-android-hw"
emulator: argv[06] = "/tmp/android-dheeraj/emulator-IJDCOv"
Concatenated QEMU options:
 ./emulator-arm -dns-server 8.8.8.8 -http-proxy http://172.20.0.99:8080 -android-hw /tmp/android-dheeraj/emulator-IJDCOv
emulator: registered 'boot-properties' qemud service
emulator: nand_add_dev: system,size=0x8000000,initfile=/opt/android-sdk-linux/platforms/android-4/images//system.img
emulator: mapping 'system' NAND image to /tmp/android-dheeraj/emulator-bhiKhz
emulator: rounding devsize up to a full eraseunit, now 8001000

WARNING: Data partition already in use. Changes will not persist!
emulator: nand_add_dev: userdata,size=0x8000000
emulator: mapping 'userdata' NAND image to /tmp/android-dheeraj/emulator-9Ay69J
emulator: rounding devsize up to a full eraseunit, now 8001000

WARNING: SD Card image already in use: /home/dheeraj/.android/avd/Android1_6.avd/sdcard.img
emulator: registered 'boot-properties' qemud service
emulator: Adding boot property: 'dalvik.vm.heapsize' = '24m'
emulator: Adding boot property: 'qemu.sf.lcd_density' = '240'
emulator: Adding boot property: 'qemu.hw.mainkeys' = '1'
emulator: Adding boot property: 'qemu.sf.fake_camera' = 'back'
DNS server name '8.8.8.8' resolved to 8.8.8.8:55
WARNING: Cache partition already in use. Changes will not persist!
emulator: nand_add_dev: cache,size=0x4200000
emulator: mapping 'cache' NAND image to /tmp/android-dheeraj/emulator-MS29Ce
emulator: Kernel parameters: qemu.gles=0 qemu=1 console=ttyS0 android.qemud=ttyS1 android.checkjni=1 ndns=1
waitpid(): No child processes
emulator: Trace file name is not set

emulator: autoconfig: -scale 0.888759
emulator: Realistic sensor emulation is not available, since the remote controller is not accessible:
 Connection refused
emulator: emulator window was out of view and was recentered

emulator: Could not open file: : No such file or directory
emulator: control console listening on port 5556, ADB on port 5557
emulator: sent '0012host:emulator:5557' to ADB server
emulator: setting up http proxy:  server=172.20.0.99 port=8080
emulator: ping program: /opt/android-sdk-linux/tools/ddms
emulator: ping command: /opt/android-sdk-linux/tools/ddms ping emulator 18.0
goldfish_fb_get_pixel_format:167: display surface,pixel format:
  bits/pixel:  16
  bytes/pixel: 2
  depth:       16
  red:         bits=5 mask=0xf800 shift=11 max=0x1f
  green:       bits=6 mask=0x7e0 shift=5 max=0x3f
  blue:        bits=5 mask=0x1f shift=0 max=0x1f
  alpha:       bits=0 mask=0x0 shift=0 max=0x0
emulator: User configuration saved to /home/dheeraj/.android/avd/Android1_6.avd/emulator-user.ini

显然它能够正确设置代理和 reslove dns-server。当我在模拟器中打开浏览器并键入主机名时,例如http://google.com它无法连接(网页不可用),但使用直接 IP 地址(173.194.32.32)它能够连接(google.com)。我无法理解出了什么问题。在发布之前我也咨询了以下线程并尝试了各种解决方案但无济于事。我想知道我的桌面浏览器(firefox 12)如何进行 dns-lookup?我还尝试了从租约文件中获取的内部 dns-servers,但结果相同。请进一步指导我。甚至我的桌面浏览器如何解析主机名的信息也将是有益的。我在stackoverflow上咨询了许多有类似问题的线程,但由于声誉的限制,无法粘贴它们的链接。代码形式:

http://developer.android.com/guide/developing/devices/emulator.html

   http://stackoverflow.com/questions/2039964/how-to-connect-android-emulator-to-the-internet

   http://androidcommunity.com/forums/f4/emulator-problem-34262/

   http://code.google.com/p/proxoid/issues/detail?id=43

   http://stackoverflow.com/questions/9876471/android-emulator-sdk-cannot-access-internet-web-page-not-available-dns-not-re

   http://stackoverflow.com/questions/9812260/cant-do-reverse-dns-lookup-on-android

我什至在eclipse中为我的项目输入了正确的运行配置-

-http-proxy http://172.20.0.99:8080 -dns-server 8.8.8.8

但得到了相同的结果。

因为这是我在 stackoverflow 社区的第一篇文章,所以我想尽可能详尽。请告知我帖子中的任何不足之处。提前致以诚挚的感谢。

4

0 回答 0