如何在项目的gradle.properties中设置代理设置?

时间:2023-01-17 12:43:04

I need to set some proxy settings for my Android Studio (v1.5.1) project (on Ubuntu). Every time I need it (e.g. when downloading an external library), Android Studio proposes to write them to gradle.properties, with no other option.

我需要为我的Android Studio(v1.5.1)项目(在Ubuntu上)设置一些代理设置。每次我需要它时(例如,在下载外部库时),Android Studio建议将它们写入gradle.properties,没有其他选项。

Since this file is version-controlled on a git repository, I need to set them somewhere else.

由于此文件是在git存储库上进行版本控制的,因此我需要将它们设置在其他位置。

Any suggestion?

有什么建议吗?

2 个解决方案

#1


3  

You can use the /home/user/.gradle/gradle.properties file.

您可以使用/home/user/.gradle/gradle.properties文件。

This file is not under version control and it is used by all projects in your machine. This file is used by gradle without any setting, and you can use it to store some reserved data for example.

此文件不受版本控制,并且由计算机中的所有项目使用。 grader使用此文件时没有任何设置,您可以使用它来存储一些保留数据。

The configuration is applied in following order (if an option is configured in multiple locations the last one wins):

配置按以下顺序应用(如果在多个位置配置选项,则最后一个获胜):

  • from gradle.properties in project build dir.
  • 来自项目构建目录中的gradle.properties。
  • from gradle.properties in gradle user home.
  • 来自gradle用户主页的gradle.properties。

#2


2  

You will need to add it to gradle.properties. You can just mark the file to be ignored by git so that you do not accidentally check in the proxy details.

您需要将其添加到gradle.properties。您可以将文件标记为git忽略,以便您不会意外地检入代理详细信息。

OR

要么

just momentarily switch to a public network when the proxy is blocking some network resources.

当代理阻止某些网络资源时,只是暂时切换到公共网络。

#1


3  

You can use the /home/user/.gradle/gradle.properties file.

您可以使用/home/user/.gradle/gradle.properties文件。

This file is not under version control and it is used by all projects in your machine. This file is used by gradle without any setting, and you can use it to store some reserved data for example.

此文件不受版本控制,并且由计算机中的所有项目使用。 grader使用此文件时没有任何设置,您可以使用它来存储一些保留数据。

The configuration is applied in following order (if an option is configured in multiple locations the last one wins):

配置按以下顺序应用(如果在多个位置配置选项,则最后一个获胜):

  • from gradle.properties in project build dir.
  • 来自项目构建目录中的gradle.properties。
  • from gradle.properties in gradle user home.
  • 来自gradle用户主页的gradle.properties。

#2


2  

You will need to add it to gradle.properties. You can just mark the file to be ignored by git so that you do not accidentally check in the proxy details.

您需要将其添加到gradle.properties。您可以将文件标记为git忽略,以便您不会意外地检入代理详细信息。

OR

要么

just momentarily switch to a public network when the proxy is blocking some network resources.

当代理阻止某些网络资源时,只是暂时切换到公共网络。