CentOS 安装 Android

前提

# java -version
# gradle -version
# ant -version
# yum install -y glibc.i686 libstdc++.i686 zlib.i686

下载安装(android-sdk_r24.4.1-linux.tgz:311MB)

# cd /usr/local/src
# wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
# tar zxvf android-sdk_r24.4.1-linux.tgz
# mv android-sdk-linux /opt/android-sdk
# ln -s /opt/android-sdk/tools/android /usr/bin/android

设置环境变量

# vi /etc/profile.d/android-sdk.sh
  export ANDROID_HOME="/opt/android-sdk"
  export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
# chmod +x /etc/profile.d/android-sdk.sh
# source /etc/profile.d/android-sdk.sh

确认版本

# which adb
# which android
# android --help
# echo $ANDROID_HOME

更新SDK

# cd /opt/android-sdk/tools
# android update sdk -u -a -t tools,platform-tools
# android update sdk -u -a -t extra-android-support,extra-android-m2repository
# android list sdk -u -a
  4- Android SDK Build-tools, revision 24.0.2
  11- Android SDK Build-tools, revision 22.0.1
  32- SDK Platform Android 5.1.1, API 22, revision 2
  35- SDK Platform Android 4.4.2, API 19, revision 4
  40- SDK Platform Android 4.0, API 14, revision 4
  120- Google APIs, Android API 22, revision 1
  122- Google APIs, Android API 19, revision 20
# android update sdk -u -a -t 4,11,32,35,40,120,122
# android list target

确认

Anttemplate

# android create project -t 1 -p /tmp/helloworld1 -k "com.example.test1" -a HelloWorld1
# cd /tmp/helloworld1
# ant debug

Gradletemplate

# android create project -g -v 1.2.3 -t 1 -p /tmp/helloworld2 -k "com.example.test2" -a HelloWorld2
# vi /tmp/helloworld2/gradle/wrapper/gradle-wrapper.properties
  distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-bin.zip
# vim ./build.gradle
  #runProguard true
  minifyEnabled true
# cd /tmp/helloworld2
# ./gradlew tasks
# ./gradlew clean assembleDebug
# ls build/outputs/apk/

AndroidNDK

下载安装AndroidNDK(android-ndk-r12b-linux-x86_64.zip:721MB)

# cd /usr/local/src 
# wget https://dl.google.com/android/repository/android-ndk-r12b-linux-x86_64.zip
# unzip android-ndk-r12b-linux-x86_64.zip
# mv android-ndk-r12b /opt/android-ndk-r12b

设置环境变量

# vi /etc/profile.d/android-ndk.sh
  export ANDROID_NDK_HOME=/opt/android-ndk-r12b
  export PATH=${PATH}:$ANDROID_NDK_HOME
# chmod +x /etc/profile.d/android-ndk.sh
# source /etc/profile.d/android-ndk.sh
# echo $ANDROID_NDK_HOME

相关推荐