Android studio - gradle failed to resolve dependencies

I installed Android Studio version 2.1.2 on my system, and if I add any dependencies to the Gradle file, then I get failed to resolve error.

It happen the all the libraries likes Picasso not only for Junit

So, I tried to add the proxy setting to the file gradle.properties

systemProp.http.proxyHost=http://xxxx/xxx
systemProp.http.proxyPort=80
systemProp.https.proxyHost=http://xxxx/xxx
systemProp.https.proxyPort=80

but I get the following error:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve junit:junit:4.12.
     Required by:
         MyApplication2:app:unspecified
      > Could not resolve junit:junit:4.12.
         > Could not get resource 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
            > Could not GET 'https://jcenter.bintray.com/junit/junit/4.12/junit-4.12.pom'.
               > http://xxxx/xxx

How to solve this problem, please help with this.

build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.muraliathmarao.myapplication"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
}
+4
source share
6 answers

You need to add the allprojects section at the end of the main build.gradle file, which defines the repositories for the modules of your project:

allprojects {
repositories {
    jcenter()
  }
}

and this is build.gradle (project)

buildscript {
 repositories {
    jcenter()
    mavenCentral()
  }

  dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
       // NOTE: Do not place your application dependencies here; they belong
       // in the individual module build.gradle files
   }
 }

allprojects {
    repositories {
       jcenter()
       mavenCentral()
 } 
}
+3
source

Android:
1. SDK
2. Android
3.

+2

, Gradle get

( ), , . , /. , Android Studio Android SDK. , Android SDK - Android SDK?

, Maven - , ( ). . https://maven.apache.org/guides/introduction/introduction-to-repositories.html#Internal_Repositories. - , , - (, , Android Studio Android SDK).

+1

:

  • accessible or not; . ( , )

  • ; gradle configuration. , gradle.

buildscript {
      repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'>     
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    } 
} 

allprojects {
    repositories {
        jcenter()
    } 
}
+1

, "buildToolsVersion" build.gradle. , sdk . buildToolVersion '24.0.0 ' '23.0.1' build.gradle

+1

, , Gradle, jar.

-1

Source: https://habr.com/ru/post/1648639/


All Articles