我在Mac上,在终端上进行Android开发。我已经成功地创建了HelloWorld项目,现在我试图从Android模拟器中的命令行运行它。哪个命令运行HelloWorld项目的模拟器?
我已经有Android工具和平台工具在我的路径。
编辑:
如何告诉模拟器从命令行运行HelloWorld项目?我已经用ant构建了这个项目。
我在Mac上,在终端上进行Android开发。我已经成功地创建了HelloWorld项目,现在我试图从Android模拟器中的命令行运行它。哪个命令运行HelloWorld项目的模拟器?
我已经有Android工具和平台工具在我的路径。
编辑:
如何告诉模拟器从命令行运行HelloWorld项目?我已经用ant构建了这个项目。
当前回答
在cmd中轻松地键入此命令。 替换Users\您的用户名\ 如果你没有这个文件重新安装android studio。
其他回答
对于自动化(CI),我们采取了如下步骤:
Frist, find SDK's tools location, and store in variable for later use. tools=$ANDROID_HOME/cmdline-tools/latest/bin arch="x86_64" package="system-images;android-23;google_apis;$arch" Ensure Android-image's downloaded. $tools/sdkmanager "$package" Accept the licenses. echo yes | $tools/sdkmanager --licenses Create AVD. echo no | $tools/avdmanager create avd --force --name MyAVD --abi google_apis/$arch --package "$package" Says "no" to "Do you wish to create a custom hardware profile? ..." Launch emulator parallel. $ANDROID_HOME/emulator/emulator -netdelay none -netspeed full -no-snapshot-load -no-snapshot -avd MyAVD > /dev/null & Build APK. ./gradlew assembleDebug At last, Android-tests (Instrumented tests) automatically detect and run on Emulator. ./gradlew connectedAndroidTest Note that because we launch Emulator parallel, you need to wait until Emulator is ready, and that before Step #7. Maybe count build-time with script, and if build takes less than what Emulator-launch takes, call sleep.
如果你有Git Bash,你可以双击打开模拟器,进行一些初始设置(仅在Windows 10中测试):
Open Git Bash. Run cd ~/AppData/Local/Android/sdk/emulator Run ./emulator -list-avds and keep note of the emulator's name. MY_EMULATOR for example. Open Notepad and add these two lines (insert your emulator's name instead of MY_EMULATOR): cd ~/AppData/Local/Android/sdk/emulator; ./emulator -avd MY_EMULATOR Save the file somewhere convinient as myfile.sh. You can change "myfile" as suits you best, but the extension .sh is needed. Open Git Bash at the directory where you stored myfile.sh and run chmod +x myfile.sh. Remember to put your file's name instead of myfile.
就是这样!从现在开始,每次你需要启动模拟器,只要找到你的myfile.sh,双击它,等待你的Android模拟器启动!
列出所有模拟器:
emulator -list-avds
运行一个带-avd标志的模拟器:
emulator -avd name-of-your-emulator
模拟器可执行文件在下面:
${ANDROID_SDK}/tools/emulator
或者,对于更新的sdk,尝试:
cd ${ANDROID_HOME}/emulator
emulator -avd name-of-your-emulator
打开CMD
打开命令提示符 在我的例子中输入模拟器的路径
C: \ adt - bundle - windows - x86_64 - 20140702 \ \ sdk工具
在我的例子中写“emulator -avd emulatorname”
-avd阿迪vd模拟器
转到模拟器所在的目录
美元{ANDROID_SDK} -工具-模拟器
从CLI检查模拟器列表
模拟器-list-avds
从列表中提取AVD
-avd模拟器{avd_name}