我刚刚将Android Studio更新为3.5.3,并为Ionic项目安装了Gradle 4.10.3。
我将此添加到了PATH变量中:
# Add the Android SDK Path
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
# emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
# avdmanager, sdkmanager
export PATH=$PATH:$ANDROID_SDK_ROOT/tools
# adb, logcat
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
如果我运行${ANDROID_SDK_ROOT}/emulator/emulator -version
,我会看到:Android emulator version 29.3.4.0 (build_id 6110076) (CL:N/A)
我的计算机上安装了一个avd,可以通过运行以下两个命令之一来使其运行:
${ANDROID_SDK_ROOT}/tools/emulator -avd Pixel_2_XL_API_27
${ANDROID_SDK_ROOT}/emulator/emulator -avd Pixel_2_XL_API_27
最近,Android似乎优先考虑了emulator
二进制文件。但是,当我从CLI运行which emulator
时,它返回:
/Users/[username]/Library/Android/sdk/tools/emulator
何时返回:
/Users/[username]/Library/Android/sdk/emulator/emulator
我不确定我在配置中做错了什么,但是我无法从Ionic项目中运行Android模拟器,因为我总是会遇到以下错误:
PANIC: Missing emulator engine program for 'x86' CPU.
是否有任何想法可以确保我能够从项目中运行模拟器?
编辑
我认为这可能与我的$PATH
变量有关。当我echo $PATH
时,将返回以下内容:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/[username]/Library/Android/sdk/platform-tools:/Users/[username]/Library/Android/sdk/tools:/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/bin:/Users/[username]/Library/Android/sdk/emulator:/Users/[username]/Library/Android/sdk/tools/bin:/Users/[username]/Library/Android/sdk/platform-tools:/Applications/Android Studio.app/Contents/gradle/gradle-4.10.3/bin
但是,这是我的整个$HOME/.bash_profile
:
# Create a JAVA_HOME variable, determined dynamically
export JAVA_HOME=$(/usr/libexec/java_home)
# Add that to the global PATH variable
export PATH=$PATH:$JAVA_HOME/bin
# Add the Android SDK Path
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
# emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
# avdmanager, sdkmanager
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
# adb, logcat
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
#Set GRADLE_HOME
export GRADLE_HOME=/Applications/Android\ Studio.app/Contents/gradle/gradle-4.10.3
export PATH=$PATH:$GRADLE_HOME/bin
/ usr / local / bin:/ usr / bin:/ bin:/ usr / sbin:/ sbin:/ Users / [用户名] / Library / Android / sdk / platform-tools在哪里$PATH
变量中的Users / [用户名] / Library / Android / sdk / tools 来自何方?