Android Studio gradle报错:Received status code 400 from server: Bad Request

I finally wrote the first blog about the pit of as.
I hope that I will have time to summarize the pits I stepped on when I finished the project...

Post the solution first : https://www.jianshu.com/p/e0ba79c83183

Really anonymous thanks to this blogger! ! !

---------Boundary line ------------------------------------

Here's the hard way to solve the problem:

I was also struggling with the project today (looking at the code while playing with my mobile phone), but suddenly reported an error at night, probably saying that a certain dependency package could not be downloaded, probably because of a network problem, dl.google.com 拒绝连接.
Then I watched various tutorials on the Internet, various proxy settings, and hosts files. As a result, when the AS was restarted, a new problem appeared (the old one was not resolved): the App run button was marked with a red cross.
Then click edit configuration to see, the bottom prompt:
project sync failed. Please fix your project and try again

I started searching again. Due to the different versions and different operating systems, I couldn't find a solution for the as version with me. Then someone recommended the command sync projects with gradle files, it seems that it can't solve my problem. So I decided to restore everything to the state of the afternoon, delete the agent, restart, and it will be fine .

But the original problem is still not solved. Since it is a network problem, it may not be able to climb over the wall. Open Google search, and it really doesn't work. So I connected to the wifi of the campus network, and I was able to Google, but dl.google.com still refused to connect.

I pinged it, and it was true that the ping failed, but it didn't make sense, the host file has been modified, do I need to restart it to take effect? ?

Since I can Google, I will go to Google to find the answer, but the result is a bunch of proxy settings, set it again, and the App is crossed again.

Then I saw another article, which probably said that the ip in hosts must be able to ping , maybe the one in the blog I searched before has expired.

I tried the ips in the host file one by one, and they all failed to ping. **Then I went to the webmaster’s home to find an ip, pinged it, stuffed it into the hosts file, and pinged the host name, and I can ping it, no need to restart haha.
Then I restarted the AS excitedly and didn't dare to hope too much, and still reported an error, but if I changed the way to report an error, there was progress!

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not download support-compat.aar (com.android.support:support-compat:26.0.0-alpha1)
   > Could not get resource 'https://maven.google.com/com/android/support/support-compat/26.0.0-alpha1/support-compat-26.0.0-alpha1.aar'.
      > Could not GET 'https://maven.google.com/com/android/support/support-compat/26.0.0-alpha1/support-compat-26.0.0-alpha1.aar'. Received status code 400 from server: Bad Request

Bad Request! This mistake seems to be easier to search, and then the blogger ushered in this blog, and then it was solved! ! ! Just
delete the proxy settings under gradle-properties (app) !

So I guessed it, probably because the ip in my previous hosts file was invalid, so I refused to connect and changed it to a fresh one.
In fact, there are many errors encountered here, but the error message is only the last one. Although there is no URL posted, I am really grateful to the programmers who are willing to share .

asleep.

Guess you like

Origin blog.csdn.net/unirrrrr/article/details/88653692
Recommended