How do I configure Androids sdkmanager command line tool to use custom repository?

和自甴很熟 提交于 2019-12-23 03:00:28

问题


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

Background:

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.

I've downloaded SDK Tools from here https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip

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

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

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.

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.

I see this error:

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...


回答1:


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:

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

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"

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



来源:https://stackoverflow.com/questions/53610346/how-do-i-configure-androids-sdkmanager-command-line-tool-to-use-custom-repositor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!