一、Gradle/Maven配置國(guó)內(nèi)鏡像源
配置方式有僅對(duì)單個(gè)項(xiàng)目生效和對(duì)所有項(xiàng)目生效兩種方式 對(duì)單個(gè)項(xiàng)目生效
1.打開(kāi)Android Studio工程文件,找到build.gradle
2.使用文本編輯器打開(kāi),默認(rèn)格式如下:
buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build3.5.1' } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }3.修改為以下內(nèi)容:
buildscript { repositories { maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/jcenter' } } dependencies { classpath 'com.android.tools.build3.5.1' } } allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/jcenter' } } } task clean(type: Delete) { delete rootProject.buildDir }對(duì)所有項(xiàng)目生效
1.打開(kāi)系統(tǒng)用戶(hù)的Gradle配置目錄
C:Usersxxx.gradle2.新建文件init.gradle(注意文件后綴名為gradle)
allprojects{ repositories { def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public' def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter' all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL." remove repo } } } maven { url ALIYUN_REPOSITORY_URL url ALIYUN_JCENTER_URL } } }
二、兩種配置國(guó)內(nèi)鏡像的方法
第一種:直接配置國(guó)內(nèi)鏡像源
國(guó)內(nèi)鏡像源地址:
1.東軟信息學(xué)院
mirrors.neusoft.edu.cn 端口:802.北京化工大學(xué)
ubuntu.buct.edu.cn/ubuntu.buct.cn 端口:803.中國(guó)科學(xué)院開(kāi)源協(xié)會(huì)
mirrors.opencas.cn (mirrors.opencas.org/mirrors.opencas.ac.cn) 端口:804.上海GDG鏡像服務(wù)器
sdk.gdgshanghai.com 端口:80005.電子科技大學(xué)
mirrors.dormforce.net 端口:80配置步驟:
1.打開(kāi)File -> setting -> Appearance & Behavior-> System Settings -> HTTP Proxy
![f841fe0c-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLmAaUJjAACKMoSEGGo914.png)
![f85d6aa2-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLmAHiMqAAG6wfLSFaE235.png)
2.點(diǎn)擊Manual proxy configuration,選中HTTP,在Host name中輸入地址,并在Port number中輸入端口號(hào)
![f887e1f6-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLmAH1cVAAGO4VQpR3w108.png)
第二種:利用host配置國(guó)內(nèi)鏡像源
1.在C盤(pán)的C:WindowsSystem32driversetc路徑下找到hosts文件,并用記事本打開(kāi)(或者用notepad++)
![f89a42b0-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLmACq-iAAB3ttX1ntQ653.png)
![f8a83870-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLmAPDfFAAF7OmdifuM114.png)
2.打開(kāi)多個(gè)地點(diǎn)Ping服務(wù)器,網(wǎng)站測(cè)速(http://ping.chinaz.com/) - 站長(zhǎng)工具該網(wǎng)站對(duì)dl.google.com進(jìn)行ping檢測(cè),得到可以用的IP地址,并將其添加到hosts文件末尾
![f8d65520-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLqAY6iZAABr6qqc8ps762.png)
![f8ef8b08-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLqAcsOOAALk22dEx68747.png)
![f92af0da-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLqAYro3AAB6KTEIjU4248.png)
3.配置Android Studio 找到Android Studio安裝目錄,進(jìn)入bin文件夾找到studio64.exe.vmoptions,并用記事本打開(kāi)(或者用notepad++)
![f941fd7a-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLqAXZFuAAI4UjF4RPg446.png)
![f971440e-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLqAMi5GAAFq_94OHh4736.png)
4.在studio64.exe.vmoptions末尾添加以下配置:
-Djava.net.preferIPv4Stack=true-Didea.updates.url=http://dl.google.com/android/studio/patches/updates.xml -Didea.patches.url=http://dl.google.com/android/studio/patches/
![f98e6f98-4d8c-11ee-a25d-92fbcf53809c.png](https://file1.elecfans.com/web2/M00/A3/88/wKgaomT6hLqAIInTAAK2HQK7CaA379.png)
5.在Android studio中打開(kāi)File -> setting -> Appearance & Behavior-> System Settings -> HTTP Proxy,選中No proxy即可
?? ? ??
審核編輯:湯梓紅
-
Android
+關(guān)注
關(guān)注
12文章
3945瀏覽量
127927 -
Studio
+關(guān)注
關(guān)注
2文章
190瀏覽量
28832 -
編輯器
+關(guān)注
關(guān)注
1文章
806瀏覽量
31290 -
鏡像
+關(guān)注
關(guān)注
0文章
170瀏覽量
10801
原文標(biāo)題:Android Studio配置國(guó)內(nèi)鏡像源
文章出處:【微信號(hào):哆啦安全,微信公眾號(hào):哆啦安全】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
![](https://file1.elecfans.com/web2/M00/86/7F/wKgaomRmXtqAcrY6AAC8Kkhv9Cg548.png)
#Android開(kāi)發(fā) Android Studio使用及配置_2.4 Android Studio的界面和功能
![](https://file1.elecfans.com/web2/M00/86/7F/wKgaomRmXt2AZ__uAAC5U98DnKo694.png)
#Android開(kāi)發(fā) Android Studio使用及配置_2.3 Android Studio的特點(diǎn)
Android Studio由于下載的SDK Tools版本造成無(wú)法更新SDK問(wèn)題
Linux下配置Android Studio與Eclipse
教大家如何燒寫(xiě)單獨(dú)的Android鏡像
鏡像電流源原理及其應(yīng)用電路
模擬電路之精確鏡像電流源的設(shè)計(jì)
![模擬電路之精確<b class='flag-5'>鏡像</b>電流<b class='flag-5'>源</b>的設(shè)計(jì)](https://file.elecfans.com/web1/M00/B2/27/pIYBAF4EXxqAS9J1AAA6wEquAaM116.png)
國(guó)內(nèi)Docker CE 鏡像源的配置
教程分享:Pip安裝如何使用國(guó)內(nèi)鏡像源
怎樣使用配置文件修改鏡像源
Android Studio引入AI編程助手Studio Bot
![<b class='flag-5'>Android</b> <b class='flag-5'>Studio</b>引入AI編程助手<b class='flag-5'>Studio</b> Bot](https://file1.elecfans.com/web2/M00/82/B5/wKgaomRd4ryATxS5AAAx6Tvmn2s995.png)
評(píng)論