How to setup a local Android SDK repository mirror

来自koorka知识分享
Zhangzhaoxiong讨论 | 贡献2017年6月2日 (五) 10:12的版本
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索
  1. mkdir -p /opt/mirrors/android
  2. yum -y install nginx wget git libxslt xsltproc
  3. cd /opt/mirrors/android
  4. git clone https://github.com/renfeng/android-repository.git
  5. config nginx server:
    server {
        listen  80;
        server_name android.koorka.com dl.google.com dl-ssl.google.com;
        location / {
                root /opt/mirrors/android/android-repository
                autoindex off;
        }
    }

For Standalone SDK Manager

Server (Repository) setup

cd /opt/mirrors/android/android-repository

./download.sh

Client (SDK Manager) setup

MIRROR_HOST=android.koorka.com
OS=linux
#OS=darwin
#OS=windows
wget http://${MIRROR_HOST}/`wget http://${MIRROR_HOST}/studio/ -O - | perl -nle "print $& if m{android/repository/sdk-tools-${OS}-\d+.zip}"`
unzip sdk-tools-*.zip
tools/bin/sdkmanager --no_https --proxy=http --proxy_host=${MIRROR_HOST} --proxy_port=80 "patcher;v4" "extras;android;m2repository" "extras;google;m2repository" emulator "build-tools;25.0.3" "platforms;android-25" platform-tools tools "sources;android-25"

(Optional) SDK web manager setup

It's a single page app for exploring the packages downloaded. To make it work,

yum install nodejs

npm install -g bower
  1. In your web root directory, (backup your index.html, and) run
${ANDROID_REPOSITORY_HOME}/setup-sdk-web-manager.sh

It will copy over three files and one directory.

  • index.html
  • .bowerrc
  • bower.json
  • elements/
  1. Install bower (requires nodejs, https://nodejs.org/), and run the following command line
  2. bower i -F -S

For Android Studio Built-in SDK Manager

Server (Repository) setup

Note

  • Files will be downloaded to your working directory.
  • ANDROID_REPOSITORY_HOME is the directory holding the files of the project.
  • A sample httpd vhost config will be printed on download complete
${ANDROID_REPOSITORY_HOME}/download2.sh

Client (Android Studio) setup

Set environment variable before launching Android Studio.

export SDK_TEST_BASE_URL=http://android.koorka.com/android/repository/

more details, refer to: https://github.com/renfeng/android-repository