gpt4 book ai didi

android - Android Studio:互联网连接被拒绝错误

转载 作者:行者123 更新时间:2023-12-03 04:21:56 26 4
gpt4 key购买 nike

每当我尝试在Android Studio中打开项目或创建新项目时,都会遇到Gradle Project Sync错误。 Android Studio显示错误,指示“拒绝连接到互联网” 。我在Stack Overflow和Android Developers网站上搜索了可能的解决方案,但未成功。

我尝试了以下帖子和文档中提供的所有可能的解决方案,但没有一个适合我。

  • Create new project on Android, Error: Studio Unknown host 'services.gradle.org'
  • Android Studio Connection Refused
  • https://developer.android.com/studio/troubleshoot.html
  • Android Studio internet connection

  • 这是build.gradle和gradle.properties文件:

    build.gradle-
    // Top-level build file where you can add configuration options common to all sub-projects/modules.

    buildscript {

    repositories {
    jcenter()
    google()
    }
    dependencies {
    classpath 'com.android.tools.build:gradle:3.1.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
    }

    allprojects {
    repositories {
    jcenter()
    google()
    }
    }

    task clean(type: Delete) {
    delete rootProject.buildDir
    }

    gradle.properties-
    # Project-wide Gradle settings.
    # IDE (e.g. Android Studio) users:
    # Gradle settings configured through the IDE *will override*
    # any settings specified in this file.
    # For more details on how to configure your build environment visit
    # http://www.gradle.org/docs/current/userguide/build_environment.html
    # Specifies the JVM arguments used for the daemon process.
    # The setting is particularly useful for tweaking memory settings.

    org.gradle.jvmargs=-Djava.net.preferIPv4Stack=true
    systemProp.https.proxyHost=localhost
    systemProp.https.proxyPort=8080

    # When configured, Gradle will run in incubating parallel mode.
    # This option should only be used with decoupled projects. More details, visit
    # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
    # org.gradle.parallel=true

    当我使用localhost作为我的ProxyHost时,它抛出一个错误,说 拒绝连接:connect

    有人可以指导我解决此错误吗?提前致谢。

    最佳答案

    此问题导致先前安装的gradle包装器不是固有的网络访问权限。您可以通过让Android Studio管理gradle包装器来解决此问题;转到“文件/设置/构建执行部署/版本”,然后选中“使用本地gradle分发”。

    之后,在Gradle Home中将位置放入gradle目录-此时gradle 4.4是最新的;即'C:\ Program Files \ Android \ Android Studio \ gradle \ gradle-4.4'

    并在“gradle.properties”中修复或注释掉那些代理设置:

    #systemProp.http.proxyHost=127.0.0.1
    #systemProp.https.proxyHost=127.0.0.1

    #systemProp.http.proxyPort=1080
    #systemProp.https.proxyPort=1080

    关于android - Android Studio:互联网连接被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49904747/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com