Could not resolve com.android.tools.build:gradle:2.2.3

前端 未结 3 684
心在旅途
心在旅途 2020-12-10 14:32

I\'m working on a mobile app project for work, but often when I attempt to run the application it gives me the following error:

Error:A problem occur

相关标签:
3条回答
  • 2020-12-10 15:11

    The reason why it is failing is because it could not compile one of the libraries you included. Perhaps, try removing the one you suspect and try again. But most of the times, a rebuild of the project should resolve dependencies.

    0 讨论(0)
  • 2020-12-10 15:19

    I've had the same pb, managed to resolve it adding in gradle.properties

    systemProp.https.proxyHost=<my proxy hostname>
    systemProp.https.proxyPort=<my proxy port>
    

    I was missing HTTPS property, there was only HTTP setted so it was working sometimes, and not for the https links gradle used.

    0 讨论(0)
  • 2020-12-10 15:23

    It turns out the solution to my particular issue was relatively simple. The error message was a bit deceiving as this was not a problem with the offline mode switch, but rather confusion with the gradle file. Here are a few steps I took to fix the issue:

    1. For Android Studio 2.3 go to File>Settings>Gradle and select the "Use default gradle wrapper" option. Also make sure the checkbox next to "Offline work" is unchecked just in case.
    2. Click the "Apply" button
    3. Within the build.gradle file (the one named after your project) under the "Gradle Scripts" section of Android Studio make certain that your current build gradle class path matches the current version of Android Studio. An example for Android Studio 2.3:

      buildscript {
          repositories {
          jcenter()
          }
          dependencies {
              classpath 'com.android.tools.build:gradle:2.3.0'
          }
      }
      
    4. Also within the Gradle Scripts section make sure that your gradle-wrapper.properties file is referencing the correct gradle file in the distribution URL. For example for gradle 3.3:

      distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
      
    5. Navigate to C:\Program Files\Android\Android Studio\gradle and ensure there is a gradle folder with the same name as the gradle you are using. In my case I ensured there is a folder named gradle-3.3 with a zip file named gradle-3.3-all.zip. It is relatively easy to find this zip file online.

    6. Delete the .gradle folder in C:\Users\yourUser with yourUser being whichever user your Android Studio project is under.
    7. Close Android Studio and restart. It should begin the gradle sync process and rebuild the .gradle file.

    For me when I did this it also complained about not finding the gradle-3.3-all.zip file in the .gradle folder. I was able to fix this by adding the gradle-3.3-all.zip file to C:\Users\yourUser.gradle\wrapper\dists\gradle-3.3-all\55gk2rcmfc6p2dg9u9ohc3hw9. I'm not sure if the folder has the same name for everyone, but whatever the name, that is the location I went to. If all this doesn't work I would try a variation of these steps, and hopefully it works for you.

    0 讨论(0)
提交回复
热议问题