jelly bean(adnroid4.1.1)下emulator不能直接运行的问题


在Android 2.3下只要设置了ANDROID_PRODUCT_OUT环境变量emulator就可以使用了,但是在android 4.1下就不能使用了
只有刚刚make结束的时候的终端可以直接运行,新开一个终端就不行了,出现以下提示:
emulator: ERROR: You did not specify a virtual device name, and the system
directory could not be found.

If you are an Android SDK user, please use '@<name>' or '-avd <name>'
to start a given virtual device (see -help-avd for details).

Otherwise, follow the instructions in -help-disk-images to start the emulator
又不想去装sdk所以就去查代码了
在/externel/qemu/android/main-common.c下发现
AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild)函数
 809             android_build_root = getenv("ANDROID_BUILD_TOP");
 810             if (android_build_root == NULL || android_build_root[0] == 0)
 811                 break;

在上面两行中,如果android_build_root为0就直接跳出循环了
但是android_build_out = out;
在这之后
所以,829行 if (opts->avd == NULL && !android_build_out)
就都为真了
不知道是不是bug。
其实,可以将android_build_out = out;提到前面来
这样判断就不会进入,如果是非要大家设置ANDROID_BUILD_TOP环境变量
那也应该先执行以下
 813             if (!path_exists(android_build_root)) {
 814                 derror("Can't find the Android build root '%s'\n"
 815                     "Please check the definition of the ANDROID_BUILD_TOP variable.\n"
 816                     "It should point to the root of your source tree.\n",
 817                     android_build_root );
 818                 exit(2);
 819             }
再跳出循环

目前的解决方式是设置ANDROID_BUILD_TOP环境变量

相关内容