android studio gradle问题
~/.gradle/gradle.properties
# HTTP 代理配置
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=7890
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890
# 如果需要认证(通常不需要)
# systemProp.http.proxyUser=username
# systemProp.http.proxyPassword=password
# 排除国内地址(重要!)
systemProp.http.nonProxyHosts=*.local|localhost|127.0.0.1|*.dartlang.org|*.google.com|*.flutter.io
systemProp.https.nonProxyHosts=*.local|localhost|127.0.0.1|*.dartlang.org|*.google.com|*.flutter.io
# 禁用 SSL 验证(临时解决 SSL 问题)
systemProp.jdk.http.auth.tunneling.disabledSchemes=""
systemProp.jdk.https.auth.tunneling.disabledSchemes=""
cocoapod国内使用
安全上网
步骤 1: 配置 Git 使用代理(推荐)---以下需要开启代理
# 配置 Git 使用您的代理(端口 7890)
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
还会遇到问题
CocoaPods 下载器(cocoapods-downloader)没有使用 Git 代理,它直接使用 curl 下载二进制文件。需要配置 CocoaPods 使用代理。
步骤 2:配置 CocoaPods 使用代理
# 设置 CocoaPods 下载器使用代理
export https_proxy=http://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
export ALL_PROXY=http://127.0.0.1:7890
临时方案为终端直接执行上面的指令
永久方案 按需设置(推荐)
# 编辑 ~/.zshrc,添加简单的代理开关
cat >> ~/.zshrc << 'EOF'
# 代理开关
alias proxyon='export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 ALL_PROXY=http://127.0.0.1:7890 && echo "代理已开启"'
alias proxyoff='unset https_proxy http_proxy ALL_PROXY && echo "代理已关闭"'
# 默认关闭代理(安全)
proxyoff
EOF
# 重新加载
source ~/.zshrc
使用方法:
# 需要时开启代理
proxyon
pod install
# 完成后关闭
proxyoff
清理和重新安装
# 进入 iOS 目录
cd ios
# 清理缓存
pod cache clean --all
# 删除现有锁定文件
rm -f Podfile.lock
rm -rf Pods/
# 重新安装
pod install
# 检查清理后的配置
git config --global --list | grep proxy
以下国内没有安全上网
步骤 1:修改 Podfile 配置
# 在 Podfile 最顶部添加这行
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
platform :ios, '11.0'
target 'Runner' do
use_frameworks!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
步骤 2:添加镜像源到本地仓库(可选)
# 添加清华镜像源(命名为 tuna)
pod repo add tuna https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
# 查看现有源
pod repo list
如果直接pod install,可能还会报错,因为源码仍然从 GitHub 下载
问题根源:CocoaPods 镜像只影响 Podspec 索引,不影响各个库的源码下载地址
其实是失败的,最好就是安全上网了
# 在 ~/.zshrc 文件末尾添加
# 代理设置 - 根据您的代理软件调整端口
proxy_enable() {
export http_proxy="http://127.0.0.1:7890"
export HTTP_PROXY="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"
export HTTPS_PROXY="http://127.0.0.1:7890"
export ALL_PROXY="http://127.0.0.1:7890"
echo "Proxy enabled"
}
proxy_disable() {
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY ALL_PROXY
echo "Proxy disabled"
}
# 可选:启动时自动设置代理
# proxy_enable
开启代理
proxy_enable
关闭代理
proxy_disable