3

I just updated my android studio to

Android Studio 2.2 Build #AI-145.3276617, built on September 15, 2016 JRE: 1.8.0_76-release-b03 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Now when I create a new project I am getting build error.

Error:Failed to resolve: javax.inject:javax.inject:1 <a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

enter image description here

A J
  • 4,542
  • 5
  • 50
  • 80

7 Answers7

5

i have solved it gradle is not able to download dependencies. Check your internet connection

use fast internet

1
  1. Check Your internet connection - if it is okay
  2. In Android Studio, disable offline mode, if it is enabled
  3. Just refresh gradle
Seraphim's
  • 12,559
  • 20
  • 88
  • 129
Adam Staszak
  • 1,674
  • 14
  • 16
0

This errors is related to jcenter . probably jcenter doesn't support your area. I had this error too, just a few hours ago. Add this to your app level build.gradle above the buildTypes

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    mavenCentral() }

and in project level build.gradle use mavenCentral and jcenter both together in all places that you see jcenter, like this:

mavenCentral()
jcenter()
Shima Erfan
  • 335
  • 1
  • 5
  • 19
0

Don't add some codes to build.gradles or any other files

Just refresh it after connect to internet, Because it want some files to download.

You can also download that files externally but it's huge process, Better do it with android studio.

Bala555
  • 119
  • 1
  • 6
0

add the code blow in your project level build.gradle:

repositories {
    mavenCentral()
}
0

Doublecheck if you need to use the proxy server (i.e working on a corporate workstation from home may still require using the corporate proxy with the VPN link or without. In that case, don't trust the VS HTTP proxy settings, it's not supporting https, rather setup your gradle to use them:

In the gradle.properties file put:

systemProp.http.proxyHost=your_proxyserver_url
systemProp.http.proxyPort=your_proxyserver_port_number
systemProp.http.proxyUser=your_proxyserver_user_name
systemProp.http.proxyPassword=your_proxyserver_user_password
systemProp.http.nonProxyHosts=localhost
systemProp.http.auth.ntlm.domain=your_corporate_domain_name_url

systemProp.https.proxyHost=your_proxyserver_url
systemProp.https.proxyPort=your_proxyserver_port_number
systemProp.https.proxyUser=your_proxyserver_user_name
systemProp.https.proxyPassword=your_proxyserver_user_password
systemProp.https.nonProxyHosts=localhost
systemProp.https.auth.ntlm.domain=your_corporate_domain_name_url
halxinate
  • 1,509
  • 15
  • 22
0

this worked for me add the following code to the build.gradle:

repositories {
        maven { url "http://jcenter.bintray.com"}
        jcenter()
    }
Daniele
  • 4,163
  • 7
  • 44
  • 95
Mahalakshmi
  • 320
  • 2
  • 13