前言
MAC OS 10.15.1
使用Android Studio打开GIT克隆下来的新项目。
报错1:
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'. Received status code 400 from server: Bad Request
Enable Gradle 'offline mode' and sync project
报错2:
Unable to tunnel through proxy. Proxy returns "HTTP/1.1 400 Bad Request"
试了很多方法,如:
1. 手动配置本地Gradle
2. 换阿里云的maven私有仓库服务(https://maven.aliyun.com/mvn/view)
3. 勾选Gradle的Enable embedded Maven repository
4. 各种刷新、try again…
最终都没有解决,问题一直如鬼魅般纠缠不休。。。
重装Android Studio
网上的各种方法都试了无果后。
- 就开始猜想会不会是MAC OS新升级的10.15.1引起的,因为新版本苹果加了好多安全性检测,也有其它软件升了新系统后不能使用的情况
- 安装Android Studio时可能意外关闭过,或者安装时权限或安全性没有选择正确
于是,想起了,重新安装Android Studio。
首先先卸载Android Studio。
卸载Android Studio
不要直接去应用程序里面删除Android Studio,建议用下面命令行的方式干净卸载Android Studio。
- 卸载Android Studio
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
rm -Rf ~/Library/Caches/AndroidStudio*
- 删除Projects
rm -Rf ~/AndroidStudioProjects
- 删除gradle
rm -Rf ~/.gradle
- 卸载Android Virtual Devices(AVDs) and *.keystore
rm -Rf ~/.android
- 删除Android SDK Tools
rm -Rf ~/Library/Android*
~卸载Android Studio成功。
安装Android Studio
-
去官网下载Android Studio
下载地址:https://developer.android.com/studio?hl=zh-cn
我下的最新版:android-studio-ide-191.5977832-mac.dmg(3.5.2 for Mac)
- 安装Android Studio
安装Android Studio参考:
在Mac系统中 下载、安装、使用AndroidStudio
注意:有安全隐私确认时要允许。
打开新项目
打开克隆到本地的新项目,sync project一切正常了。
sync完成后又出现了一个报错:
ERROR: Failed to install the following Android SDK packages as some licences have not been accepted.
platforms;android-27 Android SDK Platform 27
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /Users/*****/Library/Android/sdk
Install missing SDK package(s)
解决方法如下:
- 打开MAC 终端。
- 进入sdk/tools/bin目录(上图红框选中的目录)
cd /Users/你的用户名/Library/Android/sdk
- 在bin目录下执行
cd tools
cd bin
./sdkmanager --licenses //执行这句是关键,它会提示你去允许认证
一直Y下去。
OK了。
回到Android Studio继续更新。
大功告成。