Android avdmanager 打印 null 并退出
Android avdmanager prints null and exits
我已经从官网下载了AndroidSDK,安装了openjdk10,将avdmanagershell文件中的变量DEFAULT_JVM_OPTS
修改为:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
为了让 avdmanager 与 Java10 一起工作,在我的 ~/.zshrc
中设置以下环境变量:
- export ANDROID_HOME="$HOME/Downloads/android/"
- export ANDROID_SDK_HOME="$HOME/.android"
- export JAVA_HOME='/usr/lib/jvm/java-10-openjdk'
并使用以下命令下载了一个 SDK:
$ANDROID_HOME/tools/bin/sdkmanager --verbose "system-images;android-25;google_apis;x86"
但是,当我尝试通过以下命令创建新的 AVD 时:
$ANDROID_HOME/tools/bin/avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
它只是打印 null
并退出。即使当我 运行
$ANDROID_HOME/tools/bin/avdmanager
它所做的一切只是打印 null。
如果可能有帮助,我再次更改了 avdmanager 文件并添加了一行打印文件准备的参数,然后将其传递给 $JAVACMD
命令。参数如下所示:
-Dcom.android.sdklib.toolsdir=/home/aonemd/Downloads/android/tools -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee -classpath /home/aonemd/Downloads/android/tools/lib/dvlib-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/jimfs-1.1.jar:/home/aonemd/Downloads/android/tools/lib/jsr305-1.3.9.jar:/home/aonemd/Downloads/android/tools/lib/repository-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/j2objc-annotations-1.1.jar:/home/aonemd/Downloads/android/tools/lib/layoutlib-api-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/gson-2.3.jar:/home/aonemd/Downloads/android/tools/lib/httpcore-4.2.5.jar:/home/aonemd/Downloads/android/tools/lib/commons-logging-1.1.1.jar:/home/aonemd/Downloads/android/tools/lib/commons-compress-1.12.jar:/home/aonemd/Downloads/android/tools/lib/annotations-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/error_prone_annotations-2.0.18.jar:/home/aonemd/Downloads/android/tools/lib/animal-sniffer-annotations-1.14.jar:/home/aonemd/Downloads/android/tools/lib/httpclient-4.2.6.jar:/home/aonemd/Downloads/android/tools/lib/commons-codec-1.6.jar:/home/aonemd/Downloads/android/tools/lib/common-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/kxml2-2.3.0.jar:/home/aonemd/Downloads/android/tools/lib/httpmime-4.1.jar:/home/aonemd/Downloads/android/tools/lib/annotations-12.0.jar:/home/aonemd/Downloads/android/tools/lib/sdklib-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/guava-22.0.jar com.android.sdklib.tool.AvdManagerCli
另外,~/.android
目录只包含这三个files/folders:
- adbkey
- adbkey.pub
- cache/
我在这里遗漏了什么吗?
我找到问题所在了。变量 DEFAULT_JVM_OPTS
应该是
DEFAULT_JVM_OPTS='"-Dcom.android.sdkmanager.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
而不是
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
我已经从官网下载了AndroidSDK,安装了openjdk10,将avdmanagershell文件中的变量DEFAULT_JVM_OPTS
修改为:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
为了让 avdmanager 与 Java10 一起工作,在我的 ~/.zshrc
中设置以下环境变量:
- export ANDROID_HOME="$HOME/Downloads/android/"
- export ANDROID_SDK_HOME="$HOME/.android"
- export JAVA_HOME='/usr/lib/jvm/java-10-openjdk'
并使用以下命令下载了一个 SDK:
$ANDROID_HOME/tools/bin/sdkmanager --verbose "system-images;android-25;google_apis;x86"
但是,当我尝试通过以下命令创建新的 AVD 时:
$ANDROID_HOME/tools/bin/avdmanager create avd -n test -k "system-images;android-25;google_apis;x86"
它只是打印 null
并退出。即使当我 运行
$ANDROID_HOME/tools/bin/avdmanager
它所做的一切只是打印 null。
如果可能有帮助,我再次更改了 avdmanager 文件并添加了一行打印文件准备的参数,然后将其传递给 $JAVACMD
命令。参数如下所示:
-Dcom.android.sdklib.toolsdir=/home/aonemd/Downloads/android/tools -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee -classpath /home/aonemd/Downloads/android/tools/lib/dvlib-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/jimfs-1.1.jar:/home/aonemd/Downloads/android/tools/lib/jsr305-1.3.9.jar:/home/aonemd/Downloads/android/tools/lib/repository-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/j2objc-annotations-1.1.jar:/home/aonemd/Downloads/android/tools/lib/layoutlib-api-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/gson-2.3.jar:/home/aonemd/Downloads/android/tools/lib/httpcore-4.2.5.jar:/home/aonemd/Downloads/android/tools/lib/commons-logging-1.1.1.jar:/home/aonemd/Downloads/android/tools/lib/commons-compress-1.12.jar:/home/aonemd/Downloads/android/tools/lib/annotations-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/error_prone_annotations-2.0.18.jar:/home/aonemd/Downloads/android/tools/lib/animal-sniffer-annotations-1.14.jar:/home/aonemd/Downloads/android/tools/lib/httpclient-4.2.6.jar:/home/aonemd/Downloads/android/tools/lib/commons-codec-1.6.jar:/home/aonemd/Downloads/android/tools/lib/common-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/kxml2-2.3.0.jar:/home/aonemd/Downloads/android/tools/lib/httpmime-4.1.jar:/home/aonemd/Downloads/android/tools/lib/annotations-12.0.jar:/home/aonemd/Downloads/android/tools/lib/sdklib-26.0.0-dev.jar:/home/aonemd/Downloads/android/tools/lib/guava-22.0.jar com.android.sdklib.tool.AvdManagerCli
另外,~/.android
目录只包含这三个files/folders:
- adbkey
- adbkey.pub
- cache/
我在这里遗漏了什么吗?
我找到问题所在了。变量 DEFAULT_JVM_OPTS
应该是
DEFAULT_JVM_OPTS='"-Dcom.android.sdkmanager.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
而不是
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'