11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

認証付き社内Proxyの落とし穴 in AndroidStudio 3.1 with gradle 4.4

Last updated at Posted at 2018-05-28

何が起きたか?

Android Studio を認証プロキシ下の社内ネットワーク環境で使おうとすると、3箇所のプロキシ設定が必要になる。パスワードに記号が含まれる場合、そのパスワードをURIエンコードするかしないかに気をつける必要がある。忘れるとハマる。

設定 場所 パスワードのURIエンコード
Android Studio Settings しない
gradle ~/.gradle/gradle.properties しない
git git config --global コマンドで設定 する

プロキシ設定方法

備忘録のため、以下に設定の詳細を書きます。

Android Studio

Android Studio のメニューから [ Settings -> Appearance & Behavior -> System Settings -> HTTP Proxy ] で設定する。

gradle

gradle.properties に記述する。

  • Windows の場合 -> C:\Users<username>.gradle\gradleproperties
  • Linux/Mac の場合 -> ~/.gradle/gradle.properties
gradle.properties
# HTTP Proxy --------------------------------
systemProp.http.proxyHost=myproxy
systemProp.http.proxyPort=8080
systemProp.http.nonProxyHosts=192.168.*
systemProp.http.proxyUser=username

# URIエンコードしない記述が正解
systemProp.http.proxyPassword=p@ssword

# 以下のようなURIエンコードした記述は不正解
systemProp.http.proxyPassword=p%40ssword
# --------------------------------------------

# HTTPS Proxy も同じ
systemProp.https.proxyHost=myproxy
systemProp.https.proxyPort=8080
systemProp.https.nonProxyHosts=192.168.*
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=p@ssword

補足
Android Studio は プロジェクト直下に gradle.properties があると、そちらを優先している。混乱しやすいので ~/.gradle/gradle.properties に統一した方が良いだろう。

Git

git コマンドで設定する。ここだけURIエンコードが必要。

git config --global http.proxy http://username:p%40ssword@myproxy:8080
git config --global https.proxy http://username:p%40ssword@myproxy:8080

確認も git コマンドで行う。

git config --list

間違った場合は削除できる。

git config --global --unset http.proxy
git config --global --unset https.proxy

反省

落とし穴にはまらないようにしたい。認証プロキシは辛み。撲滅したい。

11
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?