Android Studio:配置离线构建依赖

Android Studio: Configure offline build dependencies

美好的一天,我按照 "Configure you Android Studio Page" 中的说明安装离线构建依赖项(在此处 https://developer.android.com/studio/intro/studio-config#offline 找到)。下载 gradle 插件和 maven 依赖项,将它们解压缩到所需的文件夹中,还创建了 offline.gradle 文件,将其放在适当的文件夹中。然而,在指南中,据说要测试它是否有效,需要在 build.gradle 文件中注释存储库。问题是一旦我这样做了。我的项目无法构建。

如有任何帮助,我将不胜感激。 我的SDK:Android 10(API 29) 我所知道的: android gradle 插件(我从主站点下载)是 3.5.0-beta01

当我检查 .android/manual-offline-m2/gmaven_stable/com/android/tools/build/gradle/ 时,我看到文件夹范围从 3.0.0 到 3.4.0

依赖项中的类路径(在我的应用程序的 build.gradle 中)是 'com.android.tools.build:gradle:3.6.1'

distributionUrl (gradle-wrapper.properties)指向https://services.gradle.org/distributions/gradle-5.6.4-all.zip

我得到的错误是: 配置根项目 'TestingOfflineBuildApp' 时出现问题。 无法解析配置“:classpath”的所有工件。 找不到 com.android.tools.build:gradle:3.6.1。 在以下位置搜索:

如果我将类路径从 3.6.1 更改为 3.5.0-beta01,错误将更改为此(第二张图片)。 Error 1 Error 2 谢谢

You don't need to change anything after configuring offline build dependencies, the error you getting is by putting comments on build.gradle file (i think there is exception in this documentation step 4 (optional) and that exception is [ internet is required one time for "new Android Gradle Plugin" version download if it is not present in local repo or cache ] ).

解决方案是

  1. (如果错误显示为“我们的设置回购在本地回购中的正确位置”,那么它很好,我们的设置工作正常)

  2. 把我们前面注释的注释去掉,classpath其他应该是一样的,不用改。


注意事项:-(如果执行上述步骤后出现离线构建失败,请按照此操作)