欢迎光临

木子屋

标题: Android SDK下载慢离线下载安装方法

作者: dnawo

日期: 2012-09-22 10:13 AM

分类: Android编程

内容:
使用Android SDK Manager下载SDK，速度时快时慢，百度知道可以离线下载SDK文件，放到android-sdk\temp文件夹中再通过SDK Manager安装。
1.获取SDK下载地址
查看log window窗口，找到一个链接http://dl-ssl.google.com/android/repository/repository-7.xml，查看发现所有SDK文件名都在其中，SDK下载地址格式：
引用内容https://dl-ssl.google.com/android/repository/SDK文件名
用C#从xml文档分析出下载地址：
复制内容到剪贴板 程序代码using System;
using System.Text;
using System.Xml;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(AndoridSDK(OS.windows));
Console.ReadKey();
}
/// <summary>
/// SDK下载地址
/// </summary>
/// <param name="os"></param>
/// <returns></returns>
static string AndoridSDK(OS os)
{
StringBuilder result = new StringBuilder();
string server = "https://dl-ssl.google.com/android/repository/";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("http://dl-ssl.google.com/android/repository/repository-7.xml");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("sdk", "http://schemas.android.com/sdk/android/repository/7");
//platform
XmlNodeList nodeList = xmlDoc.SelectNodes("/sdk:sdk-repository/sdk:platform/sdk:archives/sdk:archive[@os='" + os + "' or @os='any']/sdk:url", nsmgr);
foreach (XmlNode node in nodeList)
{
result.AppendLine(server + node.InnerText);
}
//sample
nodeList = xmlDoc.SelectNodes("/sdk:sdk-repository/sdk:sample/sdk:archives/sdk:archive[@os='" + os + "' or @os='any']/sdk:url", nsmgr);
foreach (XmlNode node in nodeList)
{
result.AppendLine(server + node.InnerText);
}
//platform-tool
nodeList = xmlDoc.SelectNodes("/sdk:sdk-repository/sdk:platform-tool/sdk:archives/sdk:archive[@os='" + os + "' or @os='any']/sdk:url", nsmgr);
foreach (XmlNode node in nodeList)
{
result.AppendLine(server + node.InnerText);
}
//tool
nodeList = xmlDoc.SelectNodes("/sdk:sdk-repository/sdk:tool/sdk:archives/sdk:archive[@os='" + os + "' or @os='any']/sdk:url", nsmgr);
foreach (XmlNode node in nodeList)
{
result.AppendLine(server + node.InnerText);
}
//doc
nodeList = xmlDoc.SelectNodes("/sdk:sdk-repository/sdk:doc/sdk:archives/sdk:archive[@os='" + os + "' or @os='any']/sdk:url", nsmgr);
foreach (XmlNode node in nodeList)
{
result.AppendLine(server + node.InnerText);
}
//source
nodeList = xmlDoc.SelectNodes("/sdk:sdk-repository/sdk:source/sdk:archives/sdk:archive[@os='" + os + "' or @os='any']/sdk:url", nsmgr);
foreach (XmlNode node in nodeList)
{
result.AppendLine(server + node.InnerText);
}
return result.ToString();
}
/// <summary>
/// 操作系统
/// </summary>
enum OS
{
windows,
macosx,
linux,
any
}
}
}
选择需要安装的SDK地址放迅雷中下载，保存到android-sdk\temp，再通过SDK Manager进行安装。
2.Windows Android SDK下载地址
https://dl-ssl.google.com/android/repository/android-1.1_r1-windows.zip
https://dl-ssl.google.com/android/repository/android-1.5_r04-windows.zip
https://dl-ssl.google.com/android/repository/android-1.6_r03-windows.zip
https://dl-ssl.google.com/android/repository/android-2.0_r01-windows.zip
https://dl-ssl.google.com/android/repository/android-2.0.1_r01-windows.zip
https://dl-ssl.google.com/android/repository/android-2.1_r03-linux.zip
https://dl-ssl.google.com/android/repository/android-2.2_r03-linux.zip
https://dl-ssl.google.com/android/repository/android-2.3.1_r02-linux.zip
https://dl-ssl.google.com/android/repository/android-2.3.3_r02-linux.zip
https://dl-ssl.google.com/android/repository/android-3.0_r02-linux.zip
https://dl-ssl.google.com/android/repository/android-3.1_r03-linux.zip
https://dl-ssl.google.com/android/repository/android-3.2_r01-linux.zip
https://dl-ssl.google.com/android/repository/android-14_r03.zip
https://dl-ssl.google.com/android/repository/android-15_r03.zip
https://dl-ssl.google.com/android/repository/android-16_r02.zip
https://dl-ssl.google.com/android/repository/samples-2.1_r01-linux.zip
https://dl-ssl.google.com/android/repository/samples-2.2_r01-linux.zip
https://dl-ssl.google.com/android/repository/samples-2.3_r01-linux.zip
https://dl-ssl.google.com/android/repository/samples-2.3.3_r01-linux.zip
https://dl-ssl.google.com/android/repository/samples-3.0_r01-linux.zip
https://dl-ssl.google.com/android/repository/samples-3.1_r01-linux.zip
https://dl-ssl.google.com/android/repository/samples-3.2_r01-linux.zip
https://dl-ssl.google.com/android/repository/samples-14_r02.zip
https://dl-ssl.google.com/android/repository/samples-15_r02.zip
https://dl-ssl.google.com/android/repository/samples-16_r01.zip
https://dl-ssl.google.com/android/repository/platform-tools_r14-windows.zip
https://dl-ssl.google.com/android/repository/tools_r20.0.3-windows.zip
https://dl-ssl.google.com/android/repository/tools_r21_rc4-windows.zip
https://dl-ssl.google.com/android/repository/docs-16_r02.zip
https://dl-ssl.google.com/android/repository/sources-14_r01.zip
https://dl-ssl.google.com/android/repository/sources-15_r02.zip
https://dl-ssl.google.com/android/repository/sources-16_r02.zip

+ 查看当前日志评论 (0)

登录

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.180 ms

返回

标题: Android SDK下载慢离线下载安装方法

你没有权限发表评论

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.180 ms

返回

暂无评论

返回

────────────

木子屋

PJBlog3 v3.2.9.518 Inside.

Processed In 1.242 ms

返回