一。 virtualbox下很难将两个网络设在同一网段下,失败
Debugging Your Android App Wirelessly on an Android Smartphone
Developing for Android is very easy to set up and get started on your computer. However, a gripe shared among others, not just me, is that the Android emulatoris too slow. On my old computer, it would take 1-2 minutes for it to boot up. In debugging mode, the response time is very slow.
There are two methods:
I have a way that allows you to test your Android application on your Android smartphone withoutphysicallyconnecting your phone to your computer. All it requires is a rooted Android smartphone, and a shared wifi network between the computer and the phone.
Note: This method requires a phone with root access, and accessing adb over a wifi network might be a security concern for some. Take this method for what it’s worth. If you are doing this on your own home network that is trusted and encrypted there shouldn’t be a problem, but I would avoid doing this in a public wifi network.
Make sure you are connected to the same local network that your computer is on viaWiFi. You will then need an app calledadbWireless, it allows a rooted phone to allow adb connection to your phone as if it was connected by USB. Once you install adbWireless and allow root privileges, press the giant red button to begin.
It will provide you with a one-line command to run in your command prompt, something similar to “adb connect 192.168.1.106:5555″. You can type “adb devices” afterwards to verify that your device is successfully connected. That is all you have to do on the phone.
Go to Eclipse and click on the green play button so a drop-down list appears. Press “Run Configurations”.
Next, press “Target”. Change the radio button from “Automatic” to “Manual”. Press “Apply” then “Run”.
An Android Device Chooser window should appear and your device should be listed as a running Android device. Select it and press OK.
Your phone should begin downloading the app and launching it as soon as it completes. You can verify in the Console window on Eclipse that adb is running and uploading/installing the .apk on your phone.
It is pretty cool that you can wirelessly push your app to your phone to test. However, what if you can run debug mode in Eclipse while you step through the app on your phone? Well you can through this method, and it is faster than the emulator. It is not that much different from the method described above.
Make sure in your AndroidManifest.xml that “android:debuggable=true” is there. The easiest way to add this is to go to the “Application” tab in the manifest, and in “Application Attributes”, find “Debuggable”, set it to “true”, and then save. By default, my phone denies the app from being run in debug mode if the application did not explicitly declare themselves as debuggable in their manifest. So, make sure debuggable is set to true in your AndroidManifest!
Once you do that, just create breakpoints, and begin the debug mode. Step through your app on your phone, and Eclipse will automatically switch to the Debug perspective when it hits a breakpoint. This is seriously really cool.
I tried searching on Google to see if anyone else had written about this cool technique, but I wasn’t able to find anything so I decided to write my own how-to. I was in the process of uninstalling apps that I don’t use anymore, and when I stumbled upon adbWireless which I downloaded but never used before, I thought about this possibility. I tried it, and it worked. This is, in my opinion, better than the other two methods mentioned above. Laziness is good.
二。尝试后 失败
http://blog.sina.com.cn/s/blog_4868f98601017xnl.html
原先整了一个ubuntu虚拟机环境,现在发现有个严重问题:虚拟硬盘创建的太大了(30G),不好拷贝。故决定重新整一个环境出来。顺便回忆一下当初环境是怎么搞的。
附录:
1.为 Ubuntu 虚拟机从设备列表中添加 USB 筛选器;
2.将真机与 PC 连接,开启真实手机中的[设置]->[应用程序]->[开发]->[USB调试]和[USB调试通知];
3.在 Ubuntu 虚拟机中查看已附加的设备列表:
$cd ~/android-sdk-linux_x86/platform-tools
$./adb devices
List of devices attached
HT02TL901063 device
注:出现以上信息说明真机已经附加成功!
如果出现以下信息,则说明真机附加失败!
List of devices attached
???????????? no permissions
通过以下命令重启服务即可使真机附加成功:
$sudo ./adb kill-server
$sudo ./adb start-server
* daemon not running. starting it now on port 5037 *
* daemon started successfully *