1、下载Android SDK
官网链接:https://developer.android.com/studio#downloads 镜像链接:http://www.android-studio.org/index.php/download/hisversion
2、安装SDK和环境变量配置
unzip sdk-tools-linux-4333796.zip
cd /opt/
sudo mkdir android
cd android
sudo mkdir sdk
sudo mv tools/ /opt/android/sdk/
export ANDROID_SDK=/opt/android/sdk
export PATH=${PATH}:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
source ~/.bashrc
3、Android SDK Manager在终端使用
当Android SDK tools安装后,我们可以通过sdkmanager命令在终端查看,安装,更新和移除Android SDK.
sdkmanager --version
sdkmanager --update
touch ~/.android/repositories.cfg
sdkmanager --no_https --list
sdkmanager --no_https "platforms;android-28" "platform-tools" "build-tools;28.0.3"
sdkmanager --uninstall 包名
4、检验是否安装成功
adb shell
5、报错解决 Exception in thread “main” java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
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的
6、问题:在终端中执行:sdkmanager --no_https “platforms;android-28” “platform-tools” “build-tools;28.0.3”,上报“Warning: Failed to read or create install properties file.”错误
- 解决方案:在android sdk的安装目录的bin目录中执行:sudo bash sdkmanager “platforms;android-28” “platform-tools” “build-tools;28.0.3”
cd /opt/android/sdk/tools/bin,即可完成安装
例如:
/opt/android/sdk/tools/bin$ sudo bash sdkmanager "platforms;android-28" "platform-tools" "build-tools;28.0.3"
7、问题:在终端中执行:/opt/android/sdk/tools/bin$ sudo bash sdkmanager “platforms;android-28” “platform-tools” “build-tools;28.0.3”,上报“ERROR: JAVA_HOME is set to an invalid directory: /opt/java/bin/java. Please set the JAVA_HOME variable in your environment to match the location of your Java installation.”错误
分别在~/.bashrc、/etc/profile和/etc/environment三个文件中加入
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
export JAVA_HOME=/opt/java
source ~/.bashrc
source /etc/profile
source /etc/environment
|