将gradle与android studio同步时出现问题

时间:2018-11-12 13:50:05

标签: android android-studio gradle

我有一台运行Linux Mint的笔记本电脑,该笔记本电脑大多数时候都处于离线状态。我已经安装了Android Studio 3.2.1,JDK 1.8.0_101,Gradle 4.6-all和Android-SDK 24.4.1。我下载并安装了适用于Android 4.4.2的SDK平台API 19。 回到Android Studio,我进入Settings / Build, Execution, Deployment / Gradle并检查了Offline work,我也击中了Use local gradle distribution,而Android Studio本身就是Gradle安装文件夹。 现在,当我转到Build / Make project时,它便开始构建,但它向我显示了此错误:

enter image description here

错误日志显示:

org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all artifacts for configuration ':classpath'.
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve com.android.tools.build:gradle:4.6-all.
Required by:
project :
... 102 more
Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: No cached version of com.android.tools.build:gradle:4.6-all available for offline mode.
... 128 more

这是我的build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.6-all'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

和我的gradle-wrapper.properties文件:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

我想补充一件事:这是我第一次使用Android Studio。我已经在Google上搜索了一段时间了,并且总是能找到相同的答案:检查离线工作。

我去找朋友帮忙,他告诉我删除默认布局。我不知道什么是默认布局。

我的问题是:如何使它离线工作?我需要使用其他版本的Gradle吗?我在这里想念什么?

0 个答案:

没有答案