gpt4 book ai didi

Android Studio 3.5.2 离线设置错误 : app@debug/compileClasspath

转载 作者:行者123 更新时间:2023-12-03 05:05:54 30 4
gpt4 key购买 nike

请帮忙,
在我设置并按照以下说明进行操作后:

配置离线构建依赖项

如果您想在没有网络连接的情况下构建项目,
按照以下步骤将 IDE 配置为使用离线版本的 Android Gradle 插件和 Google Maven 依赖项。

如果您还没有这样做,请从下载页面下载离线组件。

下载并解压离线组件

下载离线组件后,将其内容解压缩到以下目录,如果不存在,您可能需要创建该目录:

• 在 Windows 上:%USER_HOME%/.android/manual-offline-m2/

• 在 macOS 和 Linux 上:~/.android/manual-offline-m2/

要更新离线组件,请执行以下操作:

  • 删除 manual-offline-m2/目录内的内容。
  • 重新下载离线组件。
  • 将您下载的 ZIP 文件的内容解压缩到 manual-offline-m2/目录中。
    在 Gradle 项目中包含离线组件
    要告诉 Android 构建系统使用您下载并解压缩的离线组件,您需要创建一个脚本,如下所述。请记住,您只需创建并保存一次此脚本,即使在更新离线组件之后也是如此。
  • 使用以下路径和文件名创建一个空文本文件:
    • 在 Windows 上:%USER_HOME%/.gradle/init.d/offline.gradle
    • 在 macOS 和 Linux 上:~/.gradle/init.d/offline.gradle
  • 打开文本文件并包含以下脚本:

    def reposDir = new File(System.properties['user.home'], ".android/manual-offline-m2")

    def repos = new ArrayList()
    reposDir.eachDir {repos.add(it)
    }
    repos.sort()

    所有项目{

    构建脚本 {
    repositories {

    for (repo in repos) {

    maven {

    name = "injected_offline_${repo.name}"

    url = repo.toURI().toURL()

    }

    }

    }

    }
    存储库{
    for (repo in repos) {

    maven {

    name = "injected_offline_${repo.name}"

    url = repo.toURI().toURL()

    }

    }

    }

    }
  • 保存文本文件。

  • 我收到了这个错误:

    错误:无法解析“:app@debug/compileClasspath”的依赖关系:无法解析androidx.appcompat:appcompat:1.0.2。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    错误:无法解析“:app@debug/compileClasspath”的依赖关系:无法解析androidx.constraintlayout:constraintlayout:1.1.3。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析androidx.test.ext:junit:1.1.0。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析androidx.test.espresso:espresso-core:3.1.1。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析androidx.appcompat:appcompat:1.0.2。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    错误:无法解析“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解析androidx.constraintlayout:constraintlayout:1.1.3。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析androidx.appcompat:appcompat:1.0.2。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析androidx.constraintlayout:constraintlayout:1.1.3。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    错误:无法解析“:app@debugUnitTest/compileClasspath”的依赖关系:无法解析junit:junit:4.12。
    禁用离线模式并同步项目
    显示详细资料
    受影响的模块:app

    enter image description here

    最佳答案

    我通过还原 distributionUrl 解决了我的问题在 gradle-wrapper.properties

    use


    distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

    instead of


    distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

    并且还恢复 gradle build.gradle 中的依赖项从

    use


    classpath 'com.android.tools.build:gradle:3.4.0'

    instead of


    classpath 'com.android.tools.build:gradle:3.3.2'

    现在我的项目很好。

    关于Android Studio 3.5.2 离线设置错误 : app@debug/compileClasspath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58798957/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com