官网链接:https://developer.android.com/studio#downloads
镜像链接:http://www.android-studio.org/index.php/download/hisversion
unzip sdk-tools-linux-4333796.zip
cd /opt/
sudo mkdir android
cd android
sudo mkdir sdk
sudo mv tools/ /opt/android/sdk/
# 需要配置环境变量,在"~/.bashrc"或者/etc/profile文件中加入以下内容
export ANDROID_HOME=/opt/android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
# 让配置文件生效
source ~/.bashrc
当Android SDK tools安装后,我们可以通过sdkmanager命令在终端查看,安装,更新和移除Android SDK.
sdkmanager --version
sdkmanager --update
# 查看所有可以安装的和安装过的组件信息。
touch ~/.android/repositories.cfg
sdkmanager --no_https --list
# 安装指定版本的Android SDK
sdkmanager --no_https "platforms;android-28" "platform-tools" "build-tools;28.0.3"
# 删除SDK
sdkmanager --uninstall 包名
adb shell
#显示如下说明安装成功
# * daemon not running; starting now at tcp:5037
# * daemon started successfully
# adb: device offline
Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema at com.android.repository.api.SchemaModule S c h e m a M o d u l e V e r s i o n . < i n i t > ( S c h e m a M o d u l e . j a v a : 156 ) a t c o m . a n d r o i d . r e p o s i t o r y . a p i . S c h e m a M o d u l e . < i n i t > ( S c h e m a M o d u l e . j a v a : 75 ) a t c o m . a n d r o i d . s d k l i b . r e p o s i t o r y . A n d r o i d S d k H a n d l e r . < c l i n i t > ( A n d r o i d S d k H a n d l e r . j a v a : 81 ) a t c o m . a n d r o i d . s d k l i b . t o o l . s d k m a n a g e r . S d k M a n a g e r C l i . m a i n ( S d k M a n a g e r C l i . j a v a : 73 ) a t c o m . a n d r o i d . s d k l i b . t o o l . s d k m a n a g e r . S d k M a n a g e r C l i . m a i n ( S d k M a n a g e r C l i . j a v a : 48 ) C a u s e d b y : j a v a . l a n g . C l a s s N o t F o u n d E x c e p t i o n : j a v a x . x m l . b i n d . a n n o t a t i o n . X m l S c h e m a a t j a v a . b a s e / j d k . i n t e r n a l . l o a d e r . B u i l t i n C l a s s L o a d e r . l o a d C l a s s ( B u i l t i n C l a s s L o a d e r . j a v a : 583 ) a t j a v a . b a s e / j d k . i n t e r n a l . l o a d e r . C l a s s L o a d e r s SchemaModuleVersion.<init>(SchemaModule.java:156) at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75) at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81) at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73) at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders SchemaModuleVersion.<init>(SchemaModule.java:156)atcom.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)atcom.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)atcom.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)atcom.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)Causedby:java.lang.ClassNotFoundException:javax.xml.bind.annotation.XmlSchemaatjava.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)atjava.base/jdk.internal.loader.ClassLoadersAppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadCla
1)先查看jdk版本 在cmd窗口中输入 java -version 查看你的jdk版本。
2)如果高于1.8就降低JDK 版本到 JDK 8。也可以不用卸载(删除),重新安装1.8的
例如:
/opt/android/sdk/tools/bin$ sudo bash sdkmanager "platforms;android-28" "platform-tools" "build-tools;28.0.3"
分别在~/.bashrc、/etc/profile和/etc/environment三个文件中加入
# ~/.bashrc和/etc/profile,其中/opt/java是java sdk的安装目录
export JAVA_HOME=/opt/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
# /etc/environment
export JAVA_HOME=/opt/java
# 生效
source ~/.bashrc
source /etc/profile
source /etc/environment