Received status code 400 from server: Bad Request

一、报错信息

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project lianliankan.
> Could not resolve all artifacts for configuration :classpath.
   > Could not resolve com.android.tools.build:gradle:3.6.1.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.6.1.
         > Could not get resource https://www.jitpack.io/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom.
            > Could not GET https://www.jitpack.io/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom. Received status code 400 from server: Bad Request
      > Could not resolve com.android.tools.build:gradle:3.6.1.
         > Could not get resource https://maven.aliyun.com/repository/jcenter/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom.
            > Could not GET https://maven.aliyun.com/repository/jcenter/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom. Received status code 400 from server: Bad Request
      > Could not resolve com.android.tools.build:gradle:3.6.1.
         > Could not get resource https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom.
            > Could not GET https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom. Received status code 400 from server: Bad Request
      > Could not resolve com.android.tools.build:gradle:3.6.1.
         > Could not get resource https://maven.aliyun.com/repository/central/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom.
            > Could not GET https://maven.aliyun.com/repository/central/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom. Received status code 400 from server: Bad Request
      > Could not resolve com.android.tools.build:gradle:3.6.1.
         > Could not get resource https://maven.aliyun.com/repository/gradle-plugin/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom.
            > Could not GET https://maven.aliyun.com/repository/gradle-plugin/com/android/tools/build/gradle/3.6.1/gradle-3.6.1.pom. Received status code 400 from server: Bad Request

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.


* Get more help at https://help.gradle.org

BUILD FAILED in 1s

可以看到gradle下载完后立马报错,无法下载依赖,明明gradle下载的那么顺畅,依赖怎么可能下载不了呢,考虑了可能原因,最终找到问题是设置了代理。解决方法就是关掉代理设置。

二、解决方法

1、选择No proxy。

2、删除gradle.proprities的下面四行内容。

3、有可能会弹出提示框,直接点OK删除。

4、再重新sync同步,project构建成功!

经验分享 程序员 微信小程序 职场和发展