Android Studio 2.2 giving error while creating new project

随声附和 提交于 2019-12-04 04:38:43

问题


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>


回答1:


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

use fast internet




回答2:


  1. Check Your internet connection - if it is okay
  2. In Android Studio, disable offline mode, if it is enabled
  3. Just refresh gradle



回答3:


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()



回答4:


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.




回答5:


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

repositories {
    mavenCentral()
}



回答6:


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



回答7:


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

repositories {
        maven { url "http://jcenter.bintray.com"}
        jcenter()
    }


来源:https://stackoverflow.com/questions/39698082/android-studio-2-2-giving-error-while-creating-new-project

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