android studio error Error:Connection timed out

2019-01-26 17:22发布

I just create a new Project in the android studio and add gcm module to it.
and I keep giving this error message

Error:Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.      

and I do not use any proxy.
can anyone help me about this?

Update
now after rebuild my project i give this error

Error:A problem occurred configuring project ':app'.    
 A problem occurred configuring project ':backend'.
Could not resolve all dependencies for configuration ':backend:classpath'.
   Could not resolve com.google.appengine:gradle-appengine-plugin:1.9.18.
    Required by:
        PushStart:backend:unspecified
      Could not resolve com.google.appengine:gradle-appengine-plugin:1.9.18.
      Could not get resource 'https://jcenter.bintray.com/com/google/appengine/gradle-appengine-plugin/1.9.18/gradle-appengine-plugin-1.9.18.pom'.
      Could not GET 'https://jcenter.bintray.com/com/google/appengine/gradle-appengine-plugin/1.9.18/gradle-appengine-plugin-1.9.18.pom'.
      Connection to https://jcenter.bintray.com refused

5条回答
一夜七次
2楼-- · 2019-01-26 17:48

If you encounter these errors even without proxy or if you have downloaded a source code and unable to compile it, follow these steps:

1- Create another empty project

2- Go to File\Project Structure\project and take note Gradle Version and Android Plugin Version

3- go back to the Troubled project and use same Versions in previous path. sometimes needed to change both jcenter to mavenCentral too

4- in the Project Structure Window go app\properties and change Compile Sdk Version to Latest Version.

5- I recommend change the Target Sdk Version to latest version too (in the Flavors tab)

6- Sync, Clean and Rebuild project.

Now, the problem with gradle compiler is resolved, You may encounter with some errors about dependencies. These problems usually resolve with updating dependencies. for update dependencies to latest version use this guide provided by @Jared Kells

查看更多
Evening l夕情丶
3楼-- · 2019-01-26 18:01

The answer from this SO post might help you.

You should add the below lines in the gradle.properties file for the https setings configuration

    systemProp.https.proxyHost=www.somehost.org
    systemProp.https.proxyPort=8080
    systemProp.https.proxyUser=userid
    systemProp.https.proxyPassword=password
    systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost
查看更多
Root(大扎)
4楼-- · 2019-01-26 18:03

if you are behind proxy and your proxy is not configured in android studio, you should do below link: Error:Connection timed out: connect

and if you are configured your proxy setting or your issue is not related to proxy, you have to update your sdk handily by below path: tools>android>sdk manager>sdk tools> check any thing you need and click on OK, then your sdk become update and then click on syncrow or Try Again button.

查看更多
爷的心禁止访问
5楼-- · 2019-01-26 18:05

If you are on Win7, then your Firewall blocks Android studio from connecting. You will have to add android studio to the trusted files and bingo! everything will start working!!

查看更多
成全新的幸福
6楼-- · 2019-01-26 18:06

Just try Invalidate Caches.. Goto File->Invalidate Caches/Restart->Choose "Invalidate and Restart".

查看更多
登录 后发表回答