我遇到了一个关于运行 android 模拟器的问题,下面是详细信息。非常感谢!
我需要自动运行android模拟器,所以倾向于execve
在Linux中使用,源代码如下所示:
/*initailize passed command line\*/
char *binary = (char*)malloc(8*sizeof(char));
char **newargv = (char **)malloc(16*sizeof(char *));
newargv[0] = "/media/career/android/source/out/host/linux-x86/sdk/android-sdk_eng.corey_linux-x86/tools/emulator";
newargv[1] = "-avd";
newargv[2] = "new1";
newargv[3] = "-system";
newargv[4] = "/media/career/android/source/out/target/product/generic/system.img";
newargv[5] = "-ramdisk";
newargv[6] = "/media/career/android/source/out/target/product/generic/ramdisk.img";
newargv[7] = "-data";
newargv[8] = "/media/career/android/source/out/target/product/generic/userdata.img";
newargv[9] = NULL;
/*initialize the env value of new process(emulator) */
const char *temp = getenv("ANDROID_AVD_HOME");
envp[0] = temp;
envp[1] = getenv("PATH");
envp[2] = NULL;
/*main function*/
if (execve (binary, (char **)newargv, (char **)envp) < 0 )
environment variable:
declare -x ANDROID_AVD_HOME="/home/corey/.android/avd"
declare -x PATH="/media/career/android/source/out/host/linux-x86/sdk/android-sdk_eng.corey_linux-x86/platform-tools:/media/career/android/source/out/host/linux-x86/sdk/android-sdk_eng.corey_linux-x86/tools:
控制台显示:PANIC: Could not open: /tmp/.android/avd/new1.ini
默认情况下,我的 avd 存储路径是~/.android/avd
。但是新进程只能找到根文件系统的路径来读取可移植性不好的avd文件。实际上模拟器的过程已经运行。我专注于设置环境变量,但失败了。
请问我应该如何设置我的环境变量?