- 论坛徽章:
- 0
|
各位,我现在遇到一个问题,希望能够得到大家的帮助,先谢过。
因为项目需要做一个自动化测试android应用的平台,我需要使用程序自动化打开android的emulator进行自动化测试,所以在linux下使用execv函数操作,关键代码如下:
/*初始化execve传入命令*/
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;
/*初始化emulator进程的环境变量*/
const char *temp = getenv("ANDROID_AVD_HOME");
envp[0] = temp;
envp[1] = getenv("PATH");
envp[2] = NULL;
if (execve (binary, (char **)newargv, (char **)envp) < 0 )
结果运行报错
PANIC: Could not open: /tmp/.android/avd/new1.ini
我默认的avd存储路径为~/.android/avd
但是它却自动搜索根文件系统中的路径,我不想把avd的ini配置文件扔到/tmp/.android/avd/下,这样移植性很差,不适用项目,请问大家是否有这方面经验!?
非常感谢!! |
|