放到Android路径,执行./文件名 就可以了,又是需要更改权限chmod 777 文件

这段脚本很简单,首先先执行repo sync,如果失败了,就会发出错误退出信号1,由while捕获,判断如果是错误退出就继续,否则完成。主要就是“$?”这个变量,是由上一个执行完的命令返回的退出状态。


Ubuntu 12.04下配置HAXM加速Android模拟器



How to Start Intel Hardware-assisted Virtualization (hypervisor) on Linux to Speed-up Intel Android x86 Gingerbread Emulator

      The Intel Hardware Accelerated Execution Manager (Intel® HAXM) is a hardware-assisted virtualization engine (hypervisor) that uses Intel Virtualization Technology (VT) to speed up Android app emulation on a host machine. In combination with Android x86 emulator images provided by Intel and the official Android SDK Manager, HAXM allows for faster Android emulation on Intel VT enabled systems. HAXM for both Windows and IOS are available now.

Since Google mainly support Android build on Linux platform (with Ubuntu 64-bit OS as top Linux platform, and IOS as 2nd), and a lot of Android Developers are using AVD on Eclipse hosted by a Linux system, it is very critical that Android developers take advantage of Intel hardware-assisted KVM virtualization for Linux just like HAXM for Windows and IOS.

Below are the quick step-by-step's on how to install, enable KVM  on Ubuntu host platform and  start Intel Android x86 Gingerbread emulator with Intel hardware-assisted virtualization (hypervisor). The result is very pleasing and AVD runs significantly faster and smoother than without hypervisor

KVM Installation

I referred the instructions from Ubuntu community documentation page. to get KVM installed.To see if your processor supports hardware virtualization, you can review the output from this command:

I got 64. If 0 it means that your CPU doesn't support hardware virtualization.

Next is to install CPU checker:

Now you can check if your cpu supports kvm:

It means you can  run your virtual machine faster with the KVM extensions.

If you see:
"INFO: KVM is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
and then hard poweroff/poweron your system
KVM acceleration can NOT be used"

You need to go to BIOS setup and enable the VT.

Use a 64 bit kernel

Running a 64 bit kernel on the host operating system is recommended but not required.
To serve more than 2GB of RAM for your VMs, you must use a 64-bit kernel (see 32bit_and_64bit). On a 32-bit kernel install, you'll be limited to 2GB RAM at maximum for a given VM.
Also, a 64-bit system can host both 32-bit and 64-bit guests. A 32-bit system can only host 32-bit guests.
To see if your processor is 64-bit, you can run this command:

If 0 is printed, it means that your CPU is not 64-bit.

If 1 or higher, it is. Note: lm stands for Long Mode which equates to a 64-bit CPU.
Now see if your running kernel is 64-bit, just issue the following command:

x86_64 indicates a running 64-bit kernel. If you see i386, i486, i586 or i686, you're running a 32-bit kernel.

Install KVM

For Ubuntu Lucid (10.04) or later:

You may ignore the Postfix Configuration below by selecting "No Configuration"

Next is to add your <username> account to the group kvm and libvirtd

After the installation, you need to relogin so that your user account becomes an effective member of kvm and libvirtd user groups. The members of this group can run virtual machines.

Verify Installation
You can test if your install has been successful with the following command:

Start the AVD from Android SDK Directly from Terminal

Now start the Android for x86 Intel Emulator using  the following command:

Only a 64-bits Ubuntu can allow you to run allocated Memory of 2G or more. My 64-bit Ubuntu has 6G of Memory, so I used 1/3 of it for Android AVD. My AVD name is Intel_Atom_gingerbread_2.3 . '-qemu' provides the options to qemu, and '-m' specifies the amount of memory for the emulated Android (i.e. guest). If you use too small value for that, it's possible that performance is bad because of frequent swapping activities. Add '-show-kernel' to see the message from the kernel.

Start the AVD by AVD Manager in Eclipse

Below is procedures recommended by Google. If you are running the emulator from Eclipse, run your Android application with an x86-based AVD and include the KVM options:

    • In Eclipse, click your Android project folder and then select Run > Run Configurations...
    • In the left panel of the Run Configurations dialog, select your Android project run configuration or create a new configuration.
    • Click the Target tab.
    • Select the x86-based AVD you created previously.
    • In the Additional Emulator Command Line Options field, enter:

  • Run your Android project using this run configuration.

Android 中控件的ID问题


这个  android:id="@+id/MyTestView02" 中的 MyTestView02 应该从哪儿指定呢?

刚刚开始是自定义累一个 IDValue.xml文件,然后从文件里面指定ID的编号,结果,当调用findViewById( 的时候,总返回NULL

看了看代码发现,其实这个MyTestView02 只要你指定就可以了,至于是什么 ,编译器在扫描XML的时候会自动指定一个数值。关键在这个“+”符号。



Android 资源文件中经常看到如下描述

对于其中的 “+”不甚理解,查询了一些资料,得到如下结论


注意这个 textView可能还不存在,如果确实是这样,则创建一个新id并将其命名为textView 这句话是说在 这个文件中创建一个名为textView 的变量数字






构建AVD的时候,在Hardware选项中,有个New按钮,选中,其中的Property选项中有设置很多模拟器所支持的东西。有个“keyboard support”,选中,OK后。设置其指为“Yes”。问题解决了。