case01:为Android模拟器设置
-
安装必要的工具:
# create a directory for the cli-tools, and move the .zip file into the directory mkdir android_sdk cd android_sdk mv <PATH_TO_YOUR_DOWNLOADED_ZIP_FILE> . # unzip the downloaded file, and put the contents in the new directory 'latest/' unzip commandlinetools-<YOUR_PLATFORM>-8512546_latest.zip mkdir cmdline-tools/latest cd cmdline-tools/latest mv ../* . # The hierarchy of the 'android_sdk/': └- android_sdk/ ├- cmdline-tools/ ├- latest/ ├- bin/ ├- lib/ ├- NOTICE.txt └- source.properties # Install platform and build tools # You can fetch the complete list of available packages via: bin/sdkmanager --list # Install the desired package and tools via: bin/sdkmanager --install "system-images;android-33;google_apis;x86_64" # The above command will download and install the tools in the sdk_root (android_sdk/)
-
下载并安装模拟器:
bin/sdkmanager --install "emulator"
-
创建一个新的AVD设备:
bin/avdmanager create avd -n mytestdevice -k "system-images;android-33;google_apis;x86_64"
-
检查AVD设备是否可用:
# go to the 'emulator/' directory, and run the command cd ../../emulator ./emulator -list-avds # Now you should see your newly created avd device `mytestdevice`
-
运行模拟器
./emulator -avd mytestdevice
case02:为真实的Android设备设置
-
转到official site并下载 SDK平台 - 工具
-
解压缩.zip文件。您可以在提取的目录中找到 adb 二进制。
cd platform-tools # Show every available Android device ./adb devices