How to install Android SDK to all users silently on windows?

8.6k Views Asked by At

android-studio-bundle-162.4069837-windows.exe /S

is installing Android studio to c:\program files\android\android studio. and SDK to %localappdata%\android\sdk.

In some forum it is mentioned to use /AllUsers to install SDK to all users.

I tried android-studio-bundle-162.4069837-windows.exe /S /AllUsers android-studio-bundle-162.4069837-windows.exe /S /ALLUSERS

But no use, it is installing to localappdata only.

And also even with /S I am getting screen as SDK missing on every launch even after configuring it.

I tried only studio installation without SDK with

https://developer.android.com/studio/index.html

"C:\Users\uday\Downloads\android-studio-ide-162.4069837-windows.exe" /S

And through shortcut launch I am installing the SDK to programdata and given full rights to all users to that folder.

If I see the settings are in c:\users\username.Android and .AndroidStudio2.3 folders.

But the same folders if I copy to other user, it is taking the SDK folder as programdata only but giving prompt as SDK not detected and need to download again,even if I skip it and go to settings, it is showing empty there pointing to the same folder.

Any suggestions?

1

There are 1 best solutions below

0
On

There doesn't seem to be any built-in way to do it, but here is what I did. YMMV. Also, I'm doing this from the perspective of a classroom where student user profiles get wiped out at reboot.

Install A.S. 3.0.x.

Login as a limited user (no admin rights). Run A.S., go into settings, and change the SDK location to (example) c:\AndroidStudioSDK. Make sure you created this folder as the limited user.

Completely update, install desired SDKs and components, and build a project, resolving all missing components and issues.

File > Invalidate Caches and click Invalidate. Then File > Export Settings, and save it to the desktop. Then delete or move the following folders out of the user's home folder: .android, .AndroidStudio3.0, and .Gradle. Run A.S. but cancel the wizard, select Do not re-run the setup wizard, click Configure > Import settings, and import the settings.jar file from the desktop. Once it has restarted, you can click Configure > SDK Manager to verify it still points to your custom location.

Close A.S., then copy the (now small) .android and .AndroidStudio3.0 folders to c:\users\default.

Voila. Any new user that signs in should have a ready environment that points to a centrally located SDK folder. You can copy the SDK folder and the default user folders to each lab PC.

I've included a (sanitized) Windows batch file that I used when deploying.

Hope this helps.

@echo off
cd /d %0\.. & color 0e & setlocal

::this code assumes that 7zip is installed at "%ProgramFiles%\7-zip\7z.exe"

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set "installer=android-studio-ide-171.4443003-windows.exe"
set "SDKfolder=AndroidStudioSDK"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ECHO %installer%
ECHO.
ECHO Installing Android Studio...
%installer% /S

netsh advfirewall firewall add rule Name="OpenJDK Platform binary" Program="C:\Program Files\Android\Android Studio\jre\bin\java.exe" Description="Part of Android Studio" Action=Allow Direction=In Protocol=6
netsh advfirewall firewall add rule Name="OpenJDK Platform binary" Program="C:\Program Files\Android\Android Studio\jre\bin\java.exe" Description="Part of Android Studio" Action=Allow Direction=In Protocol=17

::Install Intel HAXM
cmd /c %CD%\HAXM\silent_install.bat

::Install Default user files
"%ProgramFiles%\7-zip\7z.exe" x userfolders.7z -o%CD% -y
set "defaultUserDir=%SystemDrive%\Users\Default"
if exist %defaultUserDir%\.android (rmdir /s /q %defaultUserDir%\.android)
if exist %defaultUserDir%\.AndroidStudio3.0 (rmdir /s /q %defaultUserDir%\.AndroidStudio3.0)
move %CD%\.android %SystemDrive%\Users\Default
move %CD%\.AndroidStudio3.0 %SystemDrive%\Users\Default

::Install SDK files
"%ProgramFiles%\7-zip\7z.exe" x %SDKfolder%.7z -o%CD% -y
if exist %SystemDrive%\%SDKfolder% (rmdir /s /q %SystemDrive%\%SDKfolder%)
move %CD%\%SDKfolder% %SystemDrive%\

timeout 9
:END
color & endlocal
EXIT 0