现在的位置: 首页 > 综合 > 正文

离线安装配置Android SDK方法

2018年05月08日 ⁄ 综合 ⁄ 共 9638字 ⁄ 字号 评论关闭

1. 安装SDK

   下载Android
SDK Tools only(不包含ADT和其他包),目前最新版本是r21,双击安装或者下载zip包直接解压到指定目录即可。
 

2. 安装Eclipse ADT plugin

下载最新版ADT,ADT-21.0.0.zip,在Eclipse中,点击Help->install new software->add  将压缩包的路径添加到源,然后选中刚刚添加的源,勾选要安装的Developer Tools,取消勾选Contact all update sites during install,然后点next. 直到安装全部完成。


                       图1 


                          图2

3. 重启Eclipse

在重启之后,会提示设置SDK的安装路径,或者提示SDK的安装不完全,点击确定启动Android SDK Manager,在看到图5所示的图像时,等待载入完成(Done loading packages),这样你会看到那些包还没有安装。 

4. 完成离线安装

将安装第5节方法下载好的zip文件,全部复制到SDK安装目录根目录下的temp文件夹内,不要嵌套其他子文件夹。 然后勾选相应的要安装的包,即可瞬间完成安装,不必等待其缓慢的下载速度。



                              图3

5. 原理

查看SDK Manager Log发现每次更新时,SDK Manager 都下载以下5个xml文件:

1 "http://dl-ssl.google.com/android/repository/repository-7.xml";
2 "http://dl-ssl.google.com/android/repository/addon.xml";
3 "http://software.intel.com/sites/landingpage/android/addon.xml";
4 "http://www.mips.com/global/sdk-sys-img.xml";
5 "http://download-software.intel.com/sites/landingpage/android/sys-img.xml";

编写一个简单程序,将其中的名为url的标签对应的内容,拼接在路径http://dl-ssl.google.com/android/repository/后面,即可得到所有需要的安装包的下载地址,然后可以用迅雷等下载工具进行下载,将下载好的包拷贝到SDK根目录下的temp文件夹内,再点安装时,即可直接安装,节省大量时间。(在天朝安装这些包,之有几KB的下载速度)

以下附上代码:

package urlfinder;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

/**
 * This program allow you to catch the URL of the installation packages
 * download by Android SDK Manager. Run this program and get packages'URLs
 * in the urlfile.txt, copy them to Download Tools to download them faster.
 * (The speed is extremely slow in China.)
 * Copy the downloaded packages to {your installation path of Android SDK}/temp
 * and install them fast in SDK Manager. Enjoy.
 *  
 * @author ZQY
 *
 */
public class UrlFinder {
	/* the XML files the SDK Manager read... */
	public static final String repository = "http://dl-ssl.google.com/android/repository/repository-7.xml";
	public static final String addon = "http://dl-ssl.google.com/android/repository/addon.xml";
	public static final String addon2 = "http://software.intel.com/sites/landingpage/android/addon.xml";
	public static final String sysimg = "http://www.mips.com/global/sdk-sys-img.xml";
	public static final String sysimg2 = "http://download-software.intel.com/sites/landingpage/android/sys-img.xml";
	public static final String[] repos = { repository, addon, addon2, sysimg,
			sysimg2 };

	public static void main(String[] args) throws MalformedURLException,
			DocumentException {
		BufferedWriter out = null;
		try {
			File file = new File("urlfile.txt");
			out = new BufferedWriter(new FileWriter(file));
			for (String repo : repos) {
				Document doc = read(repo);
				findurl(doc.getRootElement(), out);
			}
			out.close();
		} catch (FileNotFoundException e) {
			System.err.println("URL does not exits.");
		} catch (IOException e) {
			System.err.println("error write output file.");
		}

	}
	
	/* find the <sdk:url/> tag, and get the absolute path of the file */
	public static void findurl(Element element, BufferedWriter out)
			throws IOException {
		List<?> list = element.elements();
		for (Iterator<?> its = list.iterator(); its.hasNext();) {
			Element e = (Element) its.next();
			if (e.getName().equals("url")) {
				System.out.println("Found:" + e.getText());
				out.write("http://dl-ssl.google.com/android/repository/"
						+ e.getText() + "\n");
			}
			findurl(e, out);
		}
	}

	public static Document read(String fileName) throws MalformedURLException,
			DocumentException {
		SAXReader reader = new SAXReader();
		Document document = reader.read(new URL(fileName));
		return document;
	}
}

抓取到的下载路径:

http://dl-ssl.google.com/android/repository/android-1.1_r1-windows.zip

http://dl-ssl.google.com/android/repository/android-1.1_r1-macosx.zip


http://dl-ssl.google.com/android/repository/android-1.1_r1-linux.zip


http://dl-ssl.google.com/android/repository/android-1.5_r04-windows.zip


http://dl-ssl.google.com/android/repository/android-1.5_r04-macosx.zip


http://dl-ssl.google.com/android/repository/android-1.5_r04-linux.zip


http://dl-ssl.google.com/android/repository/android-1.6_r03-linux.zip


http://dl-ssl.google.com/android/repository/android-1.6_r03-macosx.zip


http://dl-ssl.google.com/android/repository/android-1.6_r03-windows.zip


http://dl-ssl.google.com/android/repository/android-2.0_r01-linux.zip


http://dl-ssl.google.com/android/repository/android-2.0_r01-macosx.zip


http://dl-ssl.google.com/android/repository/android-2.0_r01-windows.zip


http://dl-ssl.google.com/android/repository/android-2.0.1_r01-linux.zip


http://dl-ssl.google.com/android/repository/android-2.0.1_r01-macosx.zip


http://dl-ssl.google.com/android/repository/android-2.0.1_r01-windows.zip


http://dl-ssl.google.com/android/repository/android-2.1_r03-linux.zip


http://dl-ssl.google.com/android/repository/android-2.2_r03-linux.zip


http://dl-ssl.google.com/android/repository/android-2.3.1_r02-linux.zip


http://dl-ssl.google.com/android/repository/android-2.3.3_r02-linux.zip


http://dl-ssl.google.com/android/repository/android-3.0_r02-linux.zip


http://dl-ssl.google.com/android/repository/android-3.1_r03-linux.zip


http://dl-ssl.google.com/android/repository/android-3.2_r01-linux.zip


http://dl-ssl.google.com/android/repository/android-14_r03.zip


http://dl-ssl.google.com/android/repository/android-15_r03.zip


http://dl-ssl.google.com/android/repository/android-16_r03.zip


http://dl-ssl.google.com/android/repository/android-17_r01.zip


http://dl-ssl.google.com/android/repository/sysimg_armv7a-14_r02.zip


http://dl-ssl.google.com/android/repository/sysimg_armv7a-15_r02.zip


http://dl-ssl.google.com/android/repository/sysimg_armv7a-16_r03.zip


http://dl-ssl.google.com/android/repository/sysimg_armv7a-17_r01.zip


http://dl-ssl.google.com/android/repository/samples-2.1_r01-linux.zip


http://dl-ssl.google.com/android/repository/samples-2.2_r01-linux.zip


http://dl-ssl.google.com/android/repository/samples-2.3_r01-linux.zip


http://dl-ssl.google.com/android/repository/samples-2.3.3_r01-linux.zip


http://dl-ssl.google.com/android/repository/samples-3.0_r01-linux.zip


http://dl-ssl.google.com/android/repository/samples-3.1_r01-linux.zip


http://dl-ssl.google.com/android/repository/samples-3.2_r01-linux.zip


http://dl-ssl.google.com/android/repository/samples-14_r02.zip


http://dl-ssl.google.com/android/repository/samples-15_r02.zip


http://dl-ssl.google.com/android/repository/samples-16_r01.zip


http://dl-ssl.google.com/android/repository/samples-17_r01.zip


http://dl-ssl.google.com/android/repository/platform-tools_r16-windows.zip


http://dl-ssl.google.com/android/repository/platform-tools_r16-linux.zip


http://dl-ssl.google.com/android/repository/platform-tools_r16-macosx.zip


http://dl-ssl.google.com/android/repository/tools_r21-windows.zip


http://dl-ssl.google.com/android/repository/tools_r21-linux.zip


http://dl-ssl.google.com/android/repository/tools_r21-macosx.zip


http://dl-ssl.google.com/android/repository/tools_r21.0.1_rc1-windows.zip


http://dl-ssl.google.com/android/repository/tools_r21.0.1_rc1-linux.zip


http://dl-ssl.google.com/android/repository/tools_r21.0.1_rc1-macosx.zip


http://dl-ssl.google.com/android/repository/docs-17_r01.zip


http://dl-ssl.google.com/android/repository/sources-14_r01.zip


http://dl-ssl.google.com/android/repository/sources-15_r02.zip


http://dl-ssl.google.com/android/repository/sources-16_r02.zip


http://dl-ssl.google.com/android/repository/sources-17_r01.zip


http://dl-ssl.google.com/android/repository/google_apis-3-r03.zip


http://dl-ssl.google.com/android/repository/google_apis-4_r02.zip


http://dl-ssl.google.com/android/repository/google_apis-5_r01.zip


http://dl-ssl.google.com/android/repository/google_apis-6_r01.zip


http://dl-ssl.google.com/android/repository/google_apis-7_r01.zip


http://dl-ssl.google.com/android/repository/google_apis-8_r02.zip


http://dl-ssl.google.com/android/repository/google_apis-9_r02.zip


http://dl-ssl.google.com/android/repository/google_apis-10_r02.zip


http://dl-ssl.google.com/android/repository/google_apis-11_r01.zip


http://dl-ssl.google.com/android/repository/google_apis-12_r01.zip


http://dl-ssl.google.com/android/repository/google_apis-13_r01.zip


http://dl-ssl.google.com/android/repository/google_apis-14_r02.zip


http://dl-ssl.google.com/android/repository/google_apis-15_r02.zip


http://dl-ssl.google.com/android/repository/google_apis-16_r03.zip


http://dl-ssl.google.com/android/repository/google_tv-12_r02.zip


http://dl-ssl.google.com/android/repository/google_apis-17_r01.zip


http://dl-ssl.google.com/android/repository/support_r11.zip


http://dl-ssl.google.com/android/repository/market_licensing-r02.zip


http://dl-ssl.google.com/android/repository/market_apk_expansion-r02.zip


http://dl-ssl.google.com/android/repository/google_play_services_2010110_r03.zip


http://dl-ssl.google.com/android/repository/usb_driver_r07-windows.zip


http://dl-ssl.google.com/android/repository/market_billing_r02.zip


https://dl-ssl.google.com/googleadmobadssdk/googleadmobadssdkandroid-6.2.1.zip


https://dl.google.com/gaformobileapps/GoogleAnalyticsAndroid_1.4.2.zip


http://dl-ssl.google.com/android/repository/webdriver_r02.zip


http://dl-ssl.google.com/android/repository/gcm_r03.zip


http://dl-ssl.google.com/android/repository/addon_intel_sysimg_2.3.7_api-10.zip


http://dl-ssl.google.com/android/repository/http://download-software.intel.com/sites/landingpage/android/extra_intel_haxm-windows_r02.zip


http://dl-ssl.google.com/android/repository/http://download-software.intel.com/sites/landingpage/android/extra_intel_haxm-macosx_r02.zip


http://dl-ssl.google.com/android/repository/http://d2a85uzpvoidrc.cloudfront.net/sysimg_mips-15_r01.zip


http://dl-ssl.google.com/android/repository/http://d2a85uzpvoidrc.cloudfront.net/sysimg_mips-16_r02.zip


http://download-software.intel.com/sites/landingpage/android/sysimg_x86-15_r01.zip


http://download-software.intel.com/sites/landingpage/android/sysimg_x86-16_r01.zip

用迅雷下载完成后,把相应的zip包放到sdk/temp目录下。再次打开SDK Manager.exe,勾选相应的sdk进行安装。完成离线安装

抱歉!评论已关闭.