Android Studio官方推荐内网离线配置

TODO

参考:https://developer.android.com/studio/intro/studio-config
版本:Android Studio 3.5.1
官方离线组件版本:[email protected], gm[email protected]

  • 按照本文下方复制的官方推荐方法配置好后,部分问题就解决了。
  • 接下来会遇到gradle版本问题。自行下载所需的gradle版本。解压到本地目录${GRADLE_ROOT}。打开设置File -> Settings -> Build, Execution, Deployment -> Gradle,选中Use local Gradle distribution,然后在下面填写${GRADLE_ROOT}。这样Android Studio就会使用你自己的Gradle版本。
  • 下面遇到的是版本问题。build过程中,遇到大量版本问题。

官方提供方法:
Turn on Offline Mode for Gradle: If you have limited bandwitch, turn on Offline Mode to prevent Gradle from attempting to download missing dependencies during your build. When Offline Mode is on, Gradle will issue a build failure if you are missing any dependencies, instead of attempting to download them. To turn on Offline Mode, do the following:

Click File > Settings (on macOS, Android Studio > Preferences) to open the Settings dialog.
In the left pane, expand Build, Execution, Deployment and then click Gradle.
Under Global Gradle settings, check the Offline work checkbox.
Click Apply or OK for your changes to take effect.

Configure offline build dependencies
If you‘d like to build your project without a network connection, follow the steps below to configure the IDE to use offline versions of the Android Gradle Plugin and Google Maven dependencies.

If you haven‘t already done so, download the offline components from the downloads page.

Download and unzip offline components
After you have downloaded the offline components, unzip their contents into the following directory, which you might need to create if it doesn’t already exist:

On Windows: %USER_HOME%/.android/manual-offline-m2/
On macOS and Linux: ~/.android/manual-offline-m2/
To update the offline components, proceed as follows:

Delete the content inside the manual-offline-m2/ directory.
Re-download the offline components.
Unzip the contents of the ZIP files you downloaded into the manual-offline-m2/ directory.
Include offline components in your Gradle project
To tell the Android build system to use the offline components you‘ve downloaded and unzipped, you need to create a script, as described below. Keep in mind, you need to create and save this script only once, even after updating your offline components.

Create an empty text file with the following path and file name:
On Windows: %USER_HOME%/.gradle/init.d/offline.gradle
On macOS and Linux: ~/.gradle/init.d/offline.gradle
Open the text file and include the following script:

def reposDir = new File(System.properties[‘user.home‘], ".android/manual-offline-m2")
def repos = new ArrayList()
reposDir.eachDir {repos.add(it) }
repos.sort()

allprojects {
buildscript {
repositories {
for (repo in repos) {
maven {
name = "injected_offline_${repo.name}"
url = repo.toURI().toURL()
}
}
}
}
repositories {
for (repo in repos) {
maven {
name = "injected_offline_${repo.name}"
url = repo.toURI().toURL()
}
}
}
}

Save the text file.

(Optional) If you’d like to verify that the offline components are working as intended, remove the online repositories from your project’s build.gradle files, as shown below. After you‘ve confirmed that your project builds correctly without these repositories, you can put them back into your build.gradle files.

buildscript {
repositories {
// Hide these repositories to test your build against
// the offline components. You can include them again after
// you‘ve confirmed that your project builds ‘offline’.
// google()
// jcenter()
}
...
}
allprojects {
repositories {
// google()
// jcenter()
}
...
}

原文地址:https://www.cnblogs.com/zhaocnblogs01/p/11729499.html

时间: 2024-10-09 12:50:10

Android Studio官方推荐内网离线配置的相关文章

Android Studio使用心得 - 简介与环境配置

关于Android Studio 在2013 Google IO大会上发布的全新IDE Android Studio相信各位猿们并不陌生,截止2014的Google IO大会,虽然依然木有发布正式版,但是根据我这几周的使用情况来说,BUG已经很少了,完全不影响正常使用.而且Android Studio是基于IntelliJ的,无论从运行速度上还是编程的快捷性上,都比Eclipse的体验要好,开发效率妥妥的提高了. Android Studio vs Eclipse ADT 目前Android S

Android Studio下项目构建的Gradle配置及打包应用变体

Gradle简介 ??Gradle是一个自动化构建工具,采用Groovy的Domain Specific Language(领域特定语言)来描述和控制构建逻辑.具有语法简洁.可读性强.配置灵活等特点.基于Intellij IDEA社区版本开发的Android Studio天生支持Gradle构建程序.Groovy是一种基于JVM的敏捷开发语言,结合了Phthon.Ruby和Smalltalk的许多强大特性.同时,Groovy代码既能够与java代码很好地结合,也能够用于扩展现有的代码. Grad

Android SDK Android NDK Android Studio 官方下载地址及方式

Android SDK Android NDK Android Studio 官方下载地址 转载自:http://home.cnblogs.com/u/yaotong/ 如果下载速度很慢或者无法下载,有三种解决方法 1.忍耐. 2.使用P2SP下载工具,比如迅雷,百度云离线. 3.你们懂得. 无法在线升级请看下边 sudo vi /etc/hosts 添加 74.125.206.93 dl-ssl.google.com 2014.7 ADT Bundle http://dl.google.com

分享Android Studio官方最新版下载(828M)

分享Android Studio官方最新版下载(828M) 百度云:http://pan.baidu.com/s/1qWp0zxU 微盘:http://share.weiyun.com/fdc8e43879c75260cafb5dce470cc0d2

.Net 转战 Android 4.4 日常笔记(5)--新软件Android Studio 0.5.8安装与配置及问题解决

原文:.Net 转战 Android 4.4 日常笔记(5)--新软件Android Studio 0.5.8安装与配置及问题解决 说真心话,Eclipse跟我们.net的VS比起来就是屌丝比高富帅,一切都是那么的难用,速度慢得我无法忍受 于是想试试Google钦点的Android Studio IDE工具,这跟ADT一样也是一套集成工具,也需要安装java JDK 1.下载最新的JDKhttp://developers.sun.com/downloads/ 我是下载JDK1.7版本,安装过程可

修改Android Studio新建工程时repositories的默认配置

个人博客 http://www.milovetingting.cn 修改Android Studio新建工程时repositories的默认配置 前言 由于众所周知的原因,Android Studio中连接google和jcenter的仓库时,会比较慢,较大机率会失败.为解决这个问题,可以设置仓库为阿里云的仓库: maven{ url 'https://maven.aliyun.com/repository/public/' } 或者设置为本地搭建的仓库,如: maven{ url 'http:

android studio 3.1.4下载安装配置(附旧版本下载地址)

windows下安装android studio.当前时间2018年9月. 最新版本的android studio3.2.0-release出来了,拥有许多新的特性 可能我是一个业余的android开发者原因,我看到两个点, 1.The new version of AAPT2 fixes many issues, including improved handling of non-ASCII characters on Windows. 修复了打包签名apk时用到了AAPT2的许多问题,主要

01-Mac下安装Android Studio注意点和安装后配置

中国地区安装教程: 1.Mac安装环境注意断网,不然要进行联网检查跟新,因为在中国谷歌服务访问受限 所有大家记得断网 2.记得选择稍后配置Android SDK路径的 3.下载Android SDK: 在设置中添加以下网址和端口 mirrors.neusoft.edu.cn 端口:80 说明以下,我自己在上海电信网络下还是下载不了,但是我后面使用了shadowsocks之后可以进行下载和安装的 shadowsocks的配置就不详细叙述了,大家作为开发者肯定配置过的 4.这样我们基本安装完成,下面

Android SDK Android NDK Android Studio 官方下载地址

如果下载速度太慢,请使用迅雷.百度云离线等方法下载. 对于Linux系统来说,如果无法在线升级请看下边 sudo vi /etc/hosts 添加 74.125.206.93 dl-ssl.google.com 以下是各下载地址. 2014.7 ADT Bundle http://dl.google.com/android/adt/adt-bundle-windows-x86-20140702.zip http://dl.google.com/android/adt/adt-bundle-win