我将Android Studio 3.1.2
与Gradle 4.4
结合使用,并且不得不强制Gradle
进行离线工作,因为当我正常(在线)使用它时,同步需要很长时间,并且失败。起初我得到这个错误:
No cached version of com.android.tools.build:gradle:3.1.2 available for offline mode.
Disable Gradle 'offline mode' and sync project
所以我下载了
gradle-3.1.2.jar
,将其放在<project root>/libs/
中,然后将项目的build.gradle
更改为以下状态:buildscript {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
现在看来以前的错误已解决,但又引发了另一个错误:
Unable to load class 'com.android.tools.lint.gradle.api.ToolingRegistryProvider'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)</li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)</li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
我该如何解决这个问题?
编辑
我知道正常的方式是在线工作,至少对于第一个版本。但是必须有一种离线添加的方法。不是这样吗?
最佳答案
这来自this link的android studio手册。
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, proceed as follows:
打开设置对话框。
Gradle 。
关于android - Android Studio离线添加 `Android plugin for Gradle`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50678385/