【问题标题】:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:multidex:1.0.3无法解析“:app@debug/compileClasspath”的依赖关系:无法解析com.android.support:multidex:1.0.3
【发布时间】:2018-08-26 07:26:50
【问题描述】:

我试图将我的 Android Studio 2.2.3 更新到版本 3,但是当我这样做时,以下错误阻止了构建过程:

无法解析 ':app@debug/compileClasspath' 的依赖关系:无法解析 com.android.support:multidex:1.0.3。

无法解析 com.android.support:multidex:1.0.3。 要求: 项目:应用程序

无法解析 com.android.support:multidex:1.0.3。

无法解析 POM https://dl.google.com/dl/android/maven2/com/android/support/multidex/1.0.3/multidex-1.0.3.pom

已经看过的文档类型。

build.gradle(模块:app):

buildscript {
    repositories {
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

apply plugin: 'com.android.application'

repositories {
    jcenter()
    flatDir {
        dirs 'libs'
    }
    google()
}

android {

    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "My.App.Id"
        minSdkVersion 17
        targetSdkVersion 26
        versionCode 111
        versionName "1.1.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:design:+'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.github.rahatarmanahmed:circularprogressview:+'
    compile files('libs/devicedriverslib.jar')
    compile files('libs/allutils.jar')
    compile 'com.android.support:multidex:1.0.3'
}

build.gradle(Project: MyProjectName)

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

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

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

}

allprojects {
    repositories {
        google()
        jcenter()
    }

}

已安装的构建工具:

gradle-wrapper.properties:

#Tue Oct 31 12:15:03 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

【问题讨论】:

  • app gradle 文件中classpath 'com.android.tools.build:gradle:3.0.1' 需要什么?
  • 这是必要的,正如samples中提到的那样

标签: android android-gradle-plugin


【解决方案1】:

如果您在防火墙后面,或者即使您在被禁止的国家/地区,您也必须通过 VPN 工具绕过限制或在防火墙中添加正确的例外。 (像 Psyphon 这样的免费代理和弱的东西是行不通的!你可能想考虑购买一个好的 VPN!)

问题在于正确的互联网连接,因此请仔细检查您的网络和互联网连接以及任何相关限制。

【讨论】:

    【解决方案2】:

    我遇到了这个问题,因为我将全局 Gradle 设置设置为离线工作

    1. 点击文件>设置(在macOS上,Android Studio >首选项)打开设置对话框。
    2. 在左侧窗格中,展开Build、Execution、Deployment,然后点击Gradle
    3. 在 Global Gradle 设置下,取消选中 Offline work 复选框。
    4. 点击应用确定使您的更改生效。
    5. 重建 Gradle

    来源:Configure Android Studio

    【讨论】:

      猜你喜欢
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-15
      • 2018-04-10
      • 2018-06-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多