Android sdk 更新慢的解决办法

<p>打开 android sdk manager 然后会出现下面的图片</p>
<p><img src="http://dl.iteye.com/upload/attachment/0073/4081/d2b4409d-835a-3eed-9759-63ae3106d63e.png" alt="" width="785" height="638"></p>
<p> </p>
<p>把所有的xml路径例如</p>
<p>https://dl-ssl.google.com/android/repository/repository-7.xml</p>
<p>放到下面的代码里面import java.util.List;</p>
<pre name="code" class="java">
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/sys-img.xml");
Element foo = doc.getRootElement();

List allChildren = foo.getChildren();
for (int i = 0; i &lt; 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 &lt; 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)
+ " 毫秒");
}

}</pre>
 
<p> </p>
<p> </p>
<p> </p>
<p>大约19行的位置;然后就会在控制台出现很多的路径,一定要把上面所有的xml路径都放一遍;然后都放到迅雷里面下载就ok了。</p>
<p>下载之后放到</p>
<p>D:\Android\android-sdk\temp 这个目录下,你的不一定是;</p>
<p>如果上面的代码超时那就是中国地区不让访问可以fan qiang解决,请看我的博客vpn的文章解决。</p>

猜你喜欢

转载自wangtianhui.iteye.com/blog/1672743