歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> jelly bean(adnroid4.1.1)下emulator不能直接運行的問題

jelly bean(adnroid4.1.1)下emulator不能直接運行的問題

日期:2017/3/1 10:11:09   编辑:Linux編程

在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環境變量

Copyright © Linux教程網 All Rights Reserved