Visual Studio 2015 install failures (Android SDK Setup) behind a Proxy


I was recently working with a customer trying to install Visual Studio 2015 in their corporate network which happened to be behind a firewall.  Access to the internet was restricted and provided with a proxy server that would allow some requests through the firewall.  When they tried to install Visual Studio 2015 on a developer desktop with the proxy configured correctly they were still seeing install failures.

The install failures showing in the UI were all the Android SDK API Levels.  These are installed for Cordova and Xamarin cross platform mobile development scenarios.

clip_image001

Looking deeper into the logs we would find errors like the following:

DownloadManager Error: 0 : Install return code for product 'Android SDK Setup (API Level 22)' is Failure (The following package(s) were not downloaded: build-tools-22.0.1 android-22 . Please check your internet connection and try again.) 
DownloadManager Information: 0 : Product Android SDK Setup (API Level 22) done install completed
DownloadManager Information: 0 : Increasing current install to 2
DownloadManager Information: 0 : Using execute progress heuristic for: Android SDK Setup (API Level 23)
DownloadManager Error: 0 : Install return code for product 'Android SDK Setup (API Level 23)' is Failure (The following package(s) were not downloaded: build-tools-23.0.1 android-23 . Please check your internet connection and try again.)
DownloadManager Information: 0 : Product Android SDK Setup (API Level 23) done install completed
DownloadManager Information: 0 : Increasing current install to 3
DownloadManager Information: 0 : Using execute progress heuristic for: Android SDK Setup (API Level 19 and 21)
DownloadManager Error: 0 : Install return code for product 'Android SDK Setup (API Level 19 and 21)' is Failure (The following package(s) were not downloaded: platform-tools extra-android-support extra-android-m2repository build-tools-19.1.0 build-tools-21.1.2 android-19 android-21 sys-img-armeabi-v7a-android-19 sys-img-x86-android-19 addon-google_apis-google-19 . Please check your internet connection and try again.)
DownloadManager Information: 0 : Product Android SDK Setup (API Level 19 and 21) done install completed

It turns out the root cause of this issue is that the Android SDK Package Manager doesn’t look to the machine-wide proxy settings when accessing the internet.  The Android SDK Package Manager stores it’s own proxy configuration instead.  Visual Studio is able to install the package manager, but the package manager can’t install any of the API levels because it doesn’t have the proxy information to access the internet through the secure firewall.

As it turns out there’s an easy fix for this issue!  We just need to help the Android SDK Package Manager with the proxy settings!  The package manager stores it’s proxy settings in a specific file in the user profile so we can put this file with the correct settings before installing Visual Studio and everything should work. 

Here are the steps to fix this issue!

  1. BEFORE installing Visual Studio, create a file at this location:  %USERPROFILE%\.android\androidtool.cfg
  2. In the androidtool.cfg file that you just created, place the following contents.  Make sure to update “http.proxyPort” and “http.proxyHost” in the file!
### Settings for Android Tool
#Fri Jan 08 02:53:27 UTC 2016
http.proxyPort=8888
sdkman.enable.previews=false
http.proxyHost=127.0.0.1
sdkman.ask.adb.restart=false
sdkman.show.update.only=true
sdkman.force.http=false
sdkman.use.dl.cache=true
  1. Install Visual Studio normally

 

Anyway, I hope that’s useful!  Post a comment below if this helped!


Comments (22)

  1. Vikas says:

    Thank you, worked perfectly for me.

    1. Great, thanks for the feedback!

  2. Graham Auty says:

    I’m getting this same problem, but I’m not sure how to proceed with your solution. My Internet Options / LAN Settings are set to “Automatically detect settings”, i.e., I’m not behind a firewall in the way you suggest (although I do have Norton Internet Security). How do I find what values to put in the file for the Port and Host? I have a couple of other machines with the same setup and they were okay. Any help would be appreciated.

    1. Hi Graham – it sounds like you’re hitting another issue if you are not behind a firewall or proxy. Could you send me email directly and we can see if I can help? My email is p h a u g e @ m i c r o s o f t dot c o m . Otherwise the Visual Studio setup forum is typically the best place for Visual Studio setup help: https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vssetup. Thanks!

  3. Zehan misgar says:

    How to update http proxy port
    I am finding solution for same problem from two days.
    And thak GOD i got answer but how to update proxy pleeees send answer to my mail also

    1. Hi Zehan – thanks for getting in touch! You can update the proxy port in the androidtool.cfg file as specified above. Just change the line: “http.proxyPort=8888” and update the port number from 8888 to the correct port.

      1. Leon says:

        but what is the correct port, how can i find out? and the host?

        1. Hi Leon – are you installing Visual Studio in a network with a proxy server (like an enterprise corporate environment for example)? If so you should contact whoever is responsible for the network for this information. The Proxy host + port are details specific to your network configuration and not standard, so it’s not something I can provide. Let me know how it goes!

  4. Chris says:

    What if the proxy server requires credentials. I’m assuming I need some additional parameters to specify a user ID and password?

    1. Hi Chris – I found an answer here: http://stackoverflow.com/questions/4562201/android-sdk-2-2-proxy-with-domain-name-is-not-working . You can add this line to the file for an authenticated proxy:

      http.proxyLogin=USER@PASSWORD

      Let us know if it works!

      1. Sebastian says:

        Hi Chris and Peter,
        I ran into the same issues as Chris, but for me the solution of Peter did not help.
        Chris, did it work for you? Are there any other suggestions for this issue?
        Thanks in advance!

        1. Is the computer attached to a domain? If so, did you try the domain syntax, “\@”? Not sure if that will work…

          There is another way you can figure this out… After you see the install failure, you’ll still find “SDK Manager” installed on the machine in the start menu. You can open up the UI and set the proxy configuration directly in the UI.

          A 3rd way that might work is here: http://kangrahmatawaludin.blogspot.com/2011/12/android-sdk-manager-peer-not.html . If your proxy server happens to not require authentication for http:// addresses, you can set the SDK manager to install this way. (to figure out the settings to type in the file, just need to check the box in the UI and then check what was written to the file… )

          Let us know if any of these work!

          1. Sebastian says:

            Yes, my machine is within a domain.
            I tried all your suggestions but still no success.
            I’m now checking with our IT if our proxy is the issue.
            If anybody has any further ideas, I would be happy.

          2. I can think of one other option, which is handle the authenticated part of the proxy connection separately. IE: use http://www.squid-cache.org/ and connect to your corporate proxy server (supports NTLM auth) and then point the android SDK config file above to the local proxy. I also looked at fiddler but it doesn’t natively support an authenticated proxy…

            Feel free to reach out to me directly to discuss more! My email is p e t e r (dot) h a u g e (at) m i c r o s o f t (dot) c o m

  5. Maria says:

    I’m facing the same issue in Visual Studio. Could you give me a workaround if Visual Studio is already installed in my PC or Do i need to uninstall Visual Studio and redo the installations again?
    Thanks in Advance

    1. Hi Maria – no worries, Visual Studio has a good ‘repair’ mechanism. You should implement the steps above to setup the proxy, then go to Add/Remove Programs, find “Microsoft Visual Studio Enterprise 2015 With Updates”, right click and choose “Change”. When the dialog comes up, you can click “Repair” at the bottom to start the process. This will reapply the packages to the machine using the settings you picked when you first installed the product… Thanks!

  6. Randi says:

    Hi! I’m having the same issue. I’m using a dongle to connect to internet.How can I change Port and host ?Thank you very much

    1. Hi Randi – I didn’t see a response from the other folks so not sure if updating the proxy file is working for an authenticated proxy… An alternative is to create a mini-proxy on your machine that handles the authentication on your behalf and then point the SDK Manager to that mini-proxy. There’s more info here: https://bharathisubramanian.wordpress.com/2010/03/10/install-android-sdk-thru-proxy-with-authentic/ , it looks like Squid Proxy is the way to go. Please let us know if it works for you!

  7. Ralph says:

    Hi Peter!

    Thank you for sharing this information!

    Best regards,

    Ralph

  8. Eiasir Arafat says:

    Hi,
    There is no folder like %MyName%\.android. Where i have to create androidtool.cfg. Please Help me.
    Eiasir Arafat.

    1. If the folder doesn’t already exist, please create it and add the .android.cfg file in. The Android SDK install will find it as long as it’s in the right place, %USERPROFILE%\.android\androidtool.cfg . Thanks!

  9. Adisone says:

    ### Settings for Android Tool
    #Fri Jan 08 02:53:27 UTC 2016
    http.proxyPort=80
    sdkman.enable.previews=false
    http.proxyHost=dl.google.com
    sdkman.ask.adb.restart=false
    sdkman.show.update.only=true
    sdkman.force.http=true
    sdkman.use.dl.cache=true

    do like this when you create the file %USERPROFILE%\.android\androidtool.cfg
    and go to C:\Program Files (x86)\Android\android-sdk , run administrator and then successful

    note : if not found %USERPROFILE%\.android\ , please install the software “android-studio-bundle-162.4069837-windows” before and then you will see the folder “.android” !!

    best regard,

    kevin

Skip to main content