使用Java 11运行Android sdkmanager
时遇到问题(不是Studio,只有SDK工具)。我不想安装JDK 8或类似的东西。有没有办法用JDK 11修复Android sdkmanager
的问题?
我已经过this answer了,它不提供Java 11的命令行修复。还有其他解决方法吗?
最佳答案
更新:如另一个答案所述,新命令行工具中的sdkmanager支持JDK 11+。旧的sdkmanager几年没有收到更新,因此此替代方法应该没有必要。检查@dmertins答案以获得链接和更多详细信息。
如果有人正在寻找Java 11上的Linux修复程序,那么我会在先前的答案基础上构建它
cd Android/tools
mkdir jaxb_lib
wget https://repo1.maven.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar -O jaxb_lib/activation.jar
wget https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.3.3/jaxb-impl-2.3.3.jar -O jaxb_lib/jaxb-impl.jar
wget https://repo1.maven.org/maven2/com/sun/istack/istack-commons-runtime/3.0.11/istack-commons-runtime-3.0.11.jar -O jaxb_lib/istack-commons-runtime.jar
wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-xjc/2.3.3/jaxb-xjc-2.3.3.jar -O jaxb_lib/jaxb-xjc.jar
wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-core/2.3.0.1/jaxb-core-2.3.0.1.jar -O jaxb_lib/jaxb-core.jar
wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-jxc/2.3.3/jaxb-jxc-2.3.3.jar -O jaxb_lib/jaxb-jxc.jar
wget https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar -O jaxb_lib/jaxb-api.jar
下载完成后(确保所有文件都已下载确定),您必须在tools/bin目录中编辑sdkmanager和avdmanager脚本。您可以手动或自动执行此操作。来自Simon Ruggier的回答(除非使用gnu-sed,否则在Mac上不起作用):
sed -ie 's%^CLASSPATH=.*%\0:$APP_HOME/jaxb_lib/*%' bin/sdkmanager bin/avdmanager
或手动向下滚动到CLASSPATH变量,然后添加我们刚刚下载的新jar,如下所示:CLASSPATH=$APP_HOME/jaxb_lib/activation.jar:$APP_HOME/jaxb_lib/jaxb-impl.jar:$APP_HOME/jaxb_lib/jaxb-xjc.jar:$APP_HOME/jaxb_lib/jaxb-core.jar:$APP_HOME/jaxb_lib/jaxb-jxc.jar:$APP_HOME/jaxb_lib/jaxb-api.jar:<etc etc...DO NOT REMOVE THE OTHER JARS!...>