Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 886
Jakob Justsen Avatar asked Dec 04 '18 10:12

Jakob Justsen


People also ask

How use Sdkmanager command line?

To use the SDK Manager to install a version of the command line tools, follow these steps: Download the latest "command line tools only" package from the Android Studio downloads page and unzip the package. Move the unzipped cmdline-tools directory into a new directory of your choice, such as android_sdk .

How do I fix android Sdkmanager not found?

To Solve Android sdkmanager tool not found in Flutter The right solution would be if you have android studio installed then the command flutter doctor and it should now prompt you to run flutter doctor –android-licenses, once you run the license command, accept all licenses by hitting Y and it should solve the problem.

How install Android SDK build tools manually?

You will need to download the Android SDK without Android Studio bundled. Go to Android SDK and navigate to the SDK Tools Only section. Copy the URL for the download that's appropriate for your build machine OS. Unzip and place the contents within your home directory.


1 Answers

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 /

like image 63
Jonas Masalskis Avatar answered Oct 18 '22 09:10

Jonas Masalskis