如何配置Android的sdkmanager命令行工具以使用自定义存储库? [英] How do I configure Androids sdkmanager command line tool to use custom repository?

查看:258
本文介绍了如何配置Android的sdkmanager命令行工具以使用自定义存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将Google的sdkmanager配置为通过自定义存储库而不是dl.google.com/android/repository下载依赖项?

Is it possible to configure Google's Android sdkmanager to download dependencies through a custom repository instead of dl.google.com/android/repository?

背景:

我正在公司防火墙后面设置一个Android构建代理,而无法直接访问Internet.我可以访问LAN上的存储库服务器,该服务器充当预配置的远程存储库的镜像.

I'm setting up an Android build agent behind a corporate firewall with no direct Internet access. I can access a repository server on LAN that acts as a mirror to pre-configured remote repositories.

我已经从此处https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip

在具有Internet访问权限的计算机上,我尝试像这样配置~/.android/repositories.cfg:

On a machine with Internet access I've tried to configure ~/.android/repositories.cfg like this:

### User Sources for Android Repository
#Fri Nov 30 12:36:38 CET 2018
enabled00=true
count=1
disp00=DB Artifactory
src00=https://dl.google.com/android/repository/repository2-1.xml

如果我在Android Studio中设置了自定义SDK更新站点,将获得哪种配置.

Which is the configuration I get if I set up a custom SDK Update Site in Android Studio.

此处下载的xml文件与Android Studio配置的文件完全相同-运行sdkmanager命令行工具时,我在Charles Proxy中观察到的文件也与此相同.

The xml file downloaded here is exactly the same as configured by Android Studio - and its also the same I observe with Charles Proxy when running the sdkmanager command line tool.

对于Android Studio中的默认"Android存储库"配置,它工作得很好,但是我的自定义配置在Android Studio中和从命令行均失败.

It works just fine for the default "Android Repository" configuration in Android Studio, but my custom configuration fails both in Android Studio and from the command line.

我看到此错误:

Step 25/34 : RUN yes | sdkmanager --licenses --proxy=http -- 
proxy_host=host.docker.internal --proxy_port=3128
 ---> Running in 8d8923c76ba7
Picked up _JAVA_OPTIONS: -XX:+UnlockExperimentalVMOptions - 
XX:+UseCGroupMemoryLimitForHeap
Warning: Errors during XML parse:       ] 42% Downloading sys-img.xml... Parse X
Warning: cvc-elt.1: Cannot find the declaration of element 'sdk:sdk-repository'.
,,Warning: org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 139; cvc-elt.1: Cannot find the declaration of element 'sdk:sdk-repository'.
Warning: javax.xml.bind.UnmarshalException - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 139; cvc-elt.1: Cannot find the declaration of element 'sdk:sdk-repository'.]
Warning: Additionally, the fallback loader failed to parse the XML. 

任何帮助将不胜感激...

Any help would be much appreciated...

推荐答案

查看

Looking at the sdkmanager's source code - there seems to be an alternative method of overriding the repository - via SDK_TEST_BASE_URL environment variable:

为了进行测试,可以将env var设置为替换默认根目录 下载网址.

For testing, the env var can be set to replace the default root download URL.

它必须以/结尾,并且其位置 更新程序将查找repository.xml,addons_list.xml等 文件.

It must end with a / and its the location where the updater will look for the repository.xml, addons_list.xml and such files.

因此,您可以执行以下操作:

Thus, you could do something like this:

SDK_TEST_BASE_URL=https://your.company/artifactory/android/ sdkmanager "platform-tools"

上面的示例将尝试使用提供的存储库URL安装platform-tools软件包. 只要确保URL以/

The example above will attempt to install platform-tools package using the provided repository URL. Just make sure the URL ends with a /

这篇关于如何配置Android的sdkmanager命令行工具以使用自定义存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆