简体   繁体   English

AndroidStudio 更新后,Gradle 项目刷新失败

[英]Gradle project refresh failed after AndroidStudio update

I built some android projects with android studio 1.4.我用 android studio 1.4 构建了一些 android 项目。 Today my computer broke and I reinstalled my operating system .今天我的电脑坏了,我重新安装了操作系统。 I installed android studio 1.5,but it didn't work with the old projects.I built some new projects and there's no errors.When I open the old projects,there is an error.我安装了android studio 1.5,但是老项目不行

Error:Unable to tunnel through proxy.错误:无法通过代理建立隧道。 Proxy returns "HTTP/1.1 400 Bad Request"代理返回“HTTP/1.1 400 错误请求”

I can't find any information about this error,how can I deal with the old projects?我找不到有关此错误的任何信息,我该如何处理旧项目? enter image description here在此处输入图片说明

Put this code in your main build.gridle file, may be it trying to use latest gradle and you have used older one in your previous projects.将此代码放在您的主 bu​​ild.gridle 文件中,可能是它试图使用最新的 gradle 而您在以前的项目中使用了旧的。

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

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

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

allprojects {
    repositories {
        jcenter()
    }
}

这个问题解决了.gradle.org/distributions/gradle-2.8-all.zip.它对我有用。

I have a network restriction at my production environment that causes this issue.我的生产环境有网络限制导致此问题。

I solved the same problem by downloading a Gradle version manually and use this local deployment directly:我通过手动下载 Gradle 版本并直接使用此本地部署解决了同样的问题:

  1. Downloading a proper Gradle version from Gradle site.从 Gradle 站点下载合适的 Gradle 版本。 In my case https://services.gradle.org/distributions/gradle-6.4.1-all.zip在我的情况下https://services.gradle.org/distributions/gradle-6.4.1-all.zip
  2. Placing this zip file in a proper disk folder, say /path/to/gradle-6.4.1-all.zip将此 zip 文件放在适当的磁盘文件夹中,例如/path/to/gradle-6.4.1-all.zip
  3. Editing projRoot > gradle > wrapper > gradle-wrapper.properties , so that编辑projRoot > gradle > wrapper > gradle-wrapper.properties ,以便
distributionUrl=file:///path/to/gradle-6.4.1-all.zip

A robust and cross-platform setup would be一个健壮的跨平台设置将是

distributionUrl=gradle-6.4.1-all.zip

This is a relative path to这是一个相对路径

project_root/android/gradle/wrapper/

So you must copy the Gradle zip ball there.所以你必须在那里复制 Gradle zip ball。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM