Android Studio 3.5.2 Offline setup Error: app@debug/compileClasspath

£可爱£侵袭症+ 提交于 2021-02-11 14:43:10

问题


Help please, After I setup and I follow this instructions:

Configure offline build dependencies

If you'd like to build your project without a network connection, follow the steps below to configure the IDE to use offline versions of the Android Gradle Plugin and Google Maven dependencies.

If you haven't already done so, download the offline components from the downloads page.

Download and unzip offline components

After you have downloaded the offline components, unzip their contents into the following directory, which you might need to create if it doesn’t already exist:

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

• On macOS and Linux: ~/.android/manual-offline-m2/

To update the offline components, proceed as follows:

  1. Delete the content inside the manual-offline-m2/ directory.
  2. Re-download the offline components.
  3. Unzip the contents of the ZIP files you downloaded into the manual-offline-m2/ directory. Include offline components in your Gradle project To tell the Android build system to use the offline components you've downloaded and unzipped, you need to create a script, as described below. Keep in mind, you need to create and save this script only once, even after updating your offline components.
  4. Create an empty text file with the following path and file name: • On Windows: %USER_HOME%/.gradle/init.d/offline.gradle • On macOS and Linux: ~/.gradle/init.d/offline.gradle
  5. Open the text file and include the following script:

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

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

    allprojects {

    buildscript {

    repositories {
    
      for (repo in repos) {
    
        maven {
    
          name = "injected_offline_${repo.name}"
    
          url = repo.toURI().toURL()
    
        }
    
      }
    
    }
    

    } repositories {

    for (repo in repos) {
    
      maven {
    
        name = "injected_offline_${repo.name}"
    
        url = repo.toURI().toURL()
    
      }
    
    }
    

    }

    }

  6. Save the text file.

I got this errors:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2. Disable offline mode and sync project Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.constraintlayout:constraintlayout:1.1.3. Disable offline mode and sync project Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.test.ext:junit:1.1.0. Disable offline mode and sync project Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.test.espresso:espresso-core:3.1.1. Disable offline mode and sync project Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2. Disable offline mode and sync project Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.constraintlayout:constraintlayout:1.1.3. Disable offline mode and sync project Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2. Disable offline mode and sync project Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.constraintlayout:constraintlayout:1.1.3. Disable offline mode and sync project Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve junit:junit:4.12. Disable offline mode and sync project Show Details Affected Modules: app


回答1:


I solved my problem by reverting distributionUrl in 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

And also reverting gradle dependency in build.gradle from

use

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

instead of

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

And now my project is fine.



来源:https://stackoverflow.com/questions/58798957/android-studio-3-5-2-offline-setup-error-appdebug-compileclasspath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!