Android SDK下载慢的最给力解决办法

最近安装Android SDK时,用SDK manager下载SDK的速度很慢,要下完需要几天时间。

难以忍受之下决定找别的解决办法。被我发现SDK Manager启动时都会检查https://dl-ssl.google.com/android/repository/repository.xml   于是进去看了下,好东西,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/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/platform-tools_r06-windows.zip

https://dl-ssl.google.com/android/repository/tools_r12-windows.zip

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

https://dl-ssl.google.com/android/repository/compatibility_r03.zip

复制下载地址到迅雷里,将下载后的文件放到android-sdk\temp文件夹下,启动SDK Manager时就会跳过该文件的下载了。

 

附上源代码:

里面限制了操作系统是windows或 any,这个可看xml文件里的定义

 

package com.hanolex.xml;
 
import java.util.List;
 
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
 
public class ParseXML {
 
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  long lasting = System.currentTimeMillis();
  try {
   SAXBuilder builder = new SAXBuilder();
   Document doc = builder
     .build("https://dl-ssl.google.com/android/repository/repository.xml");
   Element foo = doc.getRootElement();
 
   List allChildren = foo.getChildren();
   for (int i = 0; i < allChildren.size(); i++) {
    // System.out.println(((Element)allChildren.get(i)).getNamespacePrefix()+":"+((Element)allChildren.get(i)).getName());
    List child = ((Element) allChildren.get(i)).getChildren("archives", foo.getNamespace("sdk"));
    // System.out.println(child.getName());
    for (int k = 0; k < child.size(); k++) {
     // System.out.println("\t"+((Element)child.get(k)).getNamespacePrefix()+":"+((Element)child.get(k)).getName());
     List archive = ((Element) child.get(k)).getChildren();
     for (Object o : archive) {
      // System.out.println("\t\t"+((Attribute)(((Element)o).getAttributes().get(0))).getValue()
      // );
      if (((Attribute) (((Element) o).getAttributes().get(0))).getValue().equals("windows")|| ((Attribute) (((Element) o).getAttributes().get(0))).getValue().equals("any"))
       System.out.println("https://dl-ssl.google.com/android/repository/"
         + ((Element) o).getChildText("url",foo.getNamespace("sdk")));
     }
    }
 
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
  System.out.println("运行时间:" + (System.currentTimeMillis() - lasting)
    + " 毫秒");
 }
 
}

 

首发地址 http://hanolex.org/archives/300

我的博客 http://hanolex.org

你可能感兴趣的:(Android,Android,SDK,下载,解决)