43

I am installing Android Studio and I have by default the path C:\Users\Administrator\AppData\Local\Android\sdk to set my SDK. If I choose this option, some folders appeared on the path C:\Users\Administrator.

These folders are:

  • .android

  • .AndroidStudio1.3

  • .oracle_jre_usage

  • .gradle

To be a little more cleaner I tried to wrap all these folders into another folder but each time I run Android Studio it gives to me the option to configure again the settings. If I configure them again, the folders re-appeared on the path C:\Users\Administrator.

What can I do to wrap these folders into another one or to set another location for them and that the settings will be saved?


EDIT: I prove the solutions on the blog of the answer provided by Rahul Tiwari but I only could get that the folder .android will be in the new folder. The rest folders are at the same location after the changes.


EDIT 2: According to the blog provided by Rahul Tiwari to move the folder .gradle I change the default settings of Android Studio:

File > Other Settings... > Default Settings... > Build, Execution, Deployment > Gradle

Here I have as Service directory path: C:/Users/Administrator/AndroidStudio/.gradle

But the folder .gradle still appears on the path C:/Users/Administrator.


EDIT 3: Trying to remove the folder .AndroidStudio1.3 I changed these lines:

#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.plugins.path=${idea.config.path}/plugins

#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
# idea.log.path=${idea.system.path}/log

to these:

#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.plugins.path=${C:/Users/Administrator/AndroidStudio/.AndroidStudio1.3/config}/plugins

#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to IDE logs folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------
idea.log.path=${C:/Users/Administrator/AndroidStudio/.AndroidStudio1.3/system}/log

but I also couldn't move the folder.


EDIT 4: This is the blog that I mention before (Thank you very much Rahul Tiwari). I post it here because his answer was deleted.


Thanks in advance!

Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
  • 1
    possible duplicate of [Moving default AVD configuration folder (.android)](http://stackoverflow.com/questions/3109473/moving-default-avd-configuration-folder-android) – Rahul Tiwari Sep 24 '15 at 11:48
  • @RahulTiwari It still puts these folders on `C:\Users\Administrator`. – Francisco Romero Sep 24 '15 at 12:18
  • Tell us what exactly you tried. – Rahul Tiwari Sep 24 '15 at 12:26
  • @RahulTiwari I created a new folder on `C:\Users\Administrator\Android Studio` and set the `ANDROID_SDK_HOME` with that path. After, I reboot the computer and move the folders that I put above into the new folder named `Android Studio`. When I go to the `Android Studio` desktop icon to execute it, `Android Studio` again gives to me the option to configure my settings or to import them from another version of `Android Studio`. – Francisco Romero Sep 24 '15 at 12:31
  • Check carefully for any typo and try removing space from folder name 'Android Studio'. I have tried this solution and it is working fine. – Rahul Tiwari Sep 24 '15 at 12:42
  • @RahulTiwari What do you mean with "for any typo"? – Francisco Romero Sep 24 '15 at 12:42
  • from 'typo' in mean any spelling mistakes – Rahul Tiwari Sep 24 '15 at 12:44
  • @RahulTiwari Ok, now the folder `.android` it's located on the new folder but `.AndroidStudio1.3`, `oracle_jre_usage` and `.gradle` folders are still on the path `C:\Users\Administrator`. – Francisco Romero Sep 24 '15 at 13:29
  • refer first section from [blog post](http://www.littlecpu.com/android-studio-c-drive) for `.gradle` folder. I have no idea about oracle related folder though – Rahul Tiwari Sep 24 '15 at 13:34
  • @RahulTiwari Yes, I tried with the sections of `.gradle` and `.AndroidStudio1.3` but still the same behaviour. – Francisco Romero Sep 24 '15 at 13:35
  • **Look that I completed my answer with the solution for `.gradle` folder. Now I just need a solution to move `.oracle_jre_usage` folder.** – Francisco Romero Sep 30 '15 at 12:58
  • you should include link of the blog somewhere in your question and answer as well, as it is being referred everywhere and my answer got deleted. – Rahul Tiwari Sep 30 '15 at 13:42
  • @RahulTiwari Do you have the link of the blog? I didn't notice that your answer was deleted and I didn't save it. – Francisco Romero Sep 30 '15 at 18:57
  • @Heyyou I'm not sure what do you mean with your question. I found the solution to move three of the folders, but I still need a solution to move `.oracle_jre_usage` folder. Do you know a solution for that? – Francisco Romero Oct 03 '15 at 16:23
  • @Heyyou Ok thank you for your time! – Francisco Romero Oct 03 '15 at 23:12

6 Answers6

55

Finally, I got the solution to move three of the folders that I put above. I think it could be interesting to put here the problems that I faced and the changes that I made to solve them.

I'm going to investigate about the last folder, .oracle_jre_usage, and I will complete this answer if I got a solution for it. Look that I complete the solution for .gradle folder.


To move .android folder

Really, following the steps of the blog that Rahul Tiwari provided, this folder could been moved. Nevertheless I'm going to put here all the process:

  • You have to move your .android folder, after closing Android Studio (if you have it running), to the folder in which you want that it will be stored, in my case, C:\Users\Administrator\AndroidStudio.

  • BEWARE WITH THE SPACES IN THE NAME OF THE NEW FOLDER, IT COULD GIVE TO YOU PROBLEMS (AS ME). I mean, Android Studio, New Folder or similars.

  • If you are on Windows, you can do right-click on My Computer > Properties > Advanced System Settings > Environment Variables and create a new environment variable named ANDROID_SDK_HOME and as value you have to put the new path in which .android folder will be stored. It's the same path in which you have moved the .android folder in the step above.

  • Click "OK" button to accept your changes.

  • Re-launch Android Studio and look that the .android folder doesn't appear in the default path.


To move .AndroidStudio1.3 folder

With that folder I had some problems because I didn't noticed some details that were very important. Here the steps that I followed:

  • First of all, you have to close Android Studio before doing any change.

  • After, you have to move the folder .AndroidStudio1.3 to the path in which you want that it will be stored.

  • Next, you have to go to the folder in which Android Studio were installed and open "idea.properties" file and changed the lines where idea.config.path and idea.system.path appeared for the new path in which these folders are going to be located.

They have to be something similar to this:

idea.config.path=C:/Users/Administrator/AndroidStudio/.AndroidStudio1.3/config

idea.system.path=C:/Users/Administrator/AndroidStudio/.AndroidStudio1.3/system

Here I had three problems so please be careful:

  • Notice that the paths are with / and not with \ as Windows put by default.
  • DON'T CHANGE the values of idea.plugins.path and idea.log.path (My EDIT 3). Be sure that you are changing idea.config.path and idea.system.path values.
  • Uncomment the lines in which idea.config.path and idea.system.path appears. I mean, remove the # that they have at the begining of each line.
  • The last step, re-launch Android Studio.

Searching and doing some proves I also get the solution to move .gradle folder. The steps are the same as .android folder but I put here all the steps (with the values that changed) to avoid any confusion. Here it is:

To move .gradle folder

  • You have to move your .gradle folder, after closing Android Studio (if you have it running), to the folder in which you want that it will be stored, in my case, C:\Users\Administrator\AndroidStudio\.gradle.

  • BEWARE WITH THE SPACES IN THE NAME OF THE NEW FOLDER, IT COULD GIVE TO YOU PROBLEMS (AS ME). I mean, Android Studio, New Folder or similars.

  • If you are on Windows, you can do right-click on My Computer > Properties > Advanced System Settings > Environment Variables and create a new environment variable named GRADLE_USER_HOME and as value you have to put the new path in which .gradle folder will be stored. It's the same path in which you have moved the .gradle folder in the step above.

  • Click "OK" button to accept your changes.

  • Re-launch Android Studio and look that the .gradle folder doesn't appear in the default path.


Kamar
  • 312
  • 5
  • 13
Francisco Romero
  • 12,787
  • 22
  • 92
  • 167
  • 1
    Today I made an observation, although I had successfully moved `.gradle` folder to other location it got created again at its default location, but it is only having some empty folders. I think gradle is referring the configured folder however there is some bug somewhere which is creating this folder again at default location. – Rahul Tiwari Sep 25 '15 at 06:49
  • @RahulTiwari I finally found a solution to totally move the folder `.gradle`. I edited my question. Maybe it could help you. Do you know something about how to move `.oracle_jre_usage` folder? – Francisco Romero Sep 30 '15 at 13:01
  • nice efforts. seems like spaces were problems all the time ;) .Unfortunately, I did it only for 3 folders which worked for you. I don't have a JRE folder like you have. – Rahul Tiwari Sep 30 '15 at 13:06
  • Did you ever figure out the .oracle_jre_usage? – Nick H Apr 25 '16 at 05:34
  • @hitch.united Not yet. It seems that it was a bug for some versions of Java: https://bugs.openjdk.java.net/browse/JDK-8134300 – Francisco Romero Apr 25 '16 at 09:53
  • @Error404, I found that the method which you provided is not working in Android Studio version 2.2.2. The folder .AndroidStudio2.2 is still created at default location although I have changed the `idea.properties` – Wee Hong Nov 03 '16 at 00:41
  • @Kane I am sorry for that long time without giving a response but I did not seen it before. Yes, you are right. I have checked it now for Android 2.2 and it is creating two folders, 1 on the path that I have declared and another on the home path. The last one is created with an empty system folder, though. I will investigare a bit further about this these days. – Francisco Romero Jan 04 '17 at 00:03
  • @Error404, thank you for your reply. I would waiting for your reply and also trying to look for another solutions if I can get one. Thanks. – Wee Hong Jan 05 '17 at 06:08
  • no idea why it's still creating .gradle folder in C drive although I've moved it to D drive, doesn't work for me – Beeing Jk Jun 20 '18 at 04:32
  • be aware of `ANDROID_SDK_HOME` env variable, this is deprecated in Android Studio 4.2 and must be changed to 'ANDROID_PREFS_ROOT', see [here](https://developer.android.com/studio/command-line/variables) for clarification. – Andrea Nisticò Nov 04 '21 at 11:16
17

How to move data from %UserProfile%

The folders will still remain under %UserProfile%, but not the data.


Move .android

  1. Android Studio is closed
  2. Add Environment Variable

    Create "System variable":

    Variable name: ANDROID_SDK_HOME

    Variable value: D:\Android


Move .AndroidStudio

This is a example with Android Studio version 3.1

  1. Start Android Studio
  2. Help -> Edit Custom Properties...
  3. Click Yes to create file
  4. Edit file with:

    idea.config.path=D:/Android/.AndroidStudio3.1/config

    idea.system.path=D:/Android/.AndroidStudio3.1/system

  5. The file "idea.properties" is located under:

    %UserProfile%/.AndroidStudio3.1/config

  6. Close Android Studio

  7. Delete all under %UserProfile%/.AndroidStudio3.1 except the file "/config/idea.properties"
  8. Optional: Delete older version folders of .AndroidStudio

Don't edit "Android Studio/bin/idea.properties". When updating Android Studio this file is cleared.


Move .gradle

  1. Start Android Studio
  2. File -> Settings... -> Gradle
  3. Change "Service directory path" to:

    D:/Android/.gradle


Update Android Studio

  1. Start Android Studio
  2. "Import Studio settings from" is showed
  3. Select: D:/Android/.AndroidStudio3.0/config
user1564762
  • 745
  • 2
  • 11
  • 18
  • I got this error when Updating AS "Cannot find file 'D:\Android\.AndroidStudio3.0\config\settings.jar'" – Beeing Jk Jun 20 '18 at 06:29
  • @BeeingJk, Open Android Studio and do the steps 1,2,3 for "Move .AndroidStudio" and you can see were Android Studio create the file in the title bar. Look were the arrow is pointing and you can see the file location. http://cdn.ilovefreesoftware.com/wp-content/uploads/2015/07/colored-title-bar-window.png – user1564762 Jun 20 '18 at 06:31
  • Android Studio version 3.0 have another location for "idea.properties": %UserProfile%/.AndroidStudio3.0/ – user1564762 Jun 20 '18 at 06:34
  • Thanks. I have done steps 'Move .AndroidStudio', but the file location is still in C:\Users\\.AndroidStudio3.0 rather than D drive – Beeing Jk Jun 20 '18 at 06:49
  • C:\Users\kahbee\.AndroidStudio3.0\system is recreated when I open AS3.0, but inside \system is empty – Beeing Jk Jun 20 '18 at 06:50
  • the idea,.properties is created at the same level of system folder https://ibb.co/gQ84jd – Beeing Jk Jun 20 '18 at 07:00
  • 1
    The file location will always be: C:\Users\\.AndroidStudio3.0 and \system is always recreated and empty. You have done it right. Yay :) All data should now be in D:\Android\.AndroidStudio3.0\config – user1564762 Jun 20 '18 at 08:30
  • Owh..I see!! I thought an error in my build.gradle(ConfigSlurper not found) is because of that(pointing wrong path), haha..thanks a lot for pointing it out. Narrowed down the range for the error fixing. – Beeing Jk Jun 20 '18 at 08:41
  • But the error "Cannot find file 'D:\Android\.AndroidStudio3.0\config\settings.jar'" still exist, I never completed last step, doesn't it a potential issue? – Beeing Jk Jun 20 '18 at 08:43
  • Move .AndroidStudio is working fine for you? The problem is when you now start AS? Is it when you import studio settings, do this. Now you should import your old .AndroidStudio2.3 settings. It's located under %UserProfile%/.AndroidStudio2.3/config or D:/Android/.AndroidStudio2.3/config – user1564762 Jun 20 '18 at 08:51
  • Yea '.AndroidStudio3.0' is already in my D drive and I am able to launch AS3 without issue, just that if now I do "Import Studio settings" and select: D:/Android/.AndroidStudio3.0/config, it will show the error. I've lost my AS2.3 config – Beeing Jk Jun 20 '18 at 09:00
  • 1
    If you did a upgrade from AS2.3 to AS3.0 you should not import AS3.0 config, it should be AS2.3 config. – user1564762 Jun 20 '18 at 09:15
  • got it, should be OK without importing old config – Beeing Jk Jun 20 '18 at 09:27
  • 1
    The step "Update Android Studio" is to import old config. Only when you want to import old config do this step, if's not important - skip this and AS create one for you :) – user1564762 Jun 20 '18 at 09:44
  • `Move .AndroidStudio` if do this step, then it's not possible to update plugins in Android Studio, other steps works ok – user924 Sep 22 '20 at 21:39
2

I think most of the others answers address the issue, But I found more simple way for windows by adding few environment variables . (Might work for mac as well, I didn't test though)

ANDROID_SDK_ROOT - path to the SDK installation directory

default path - C:\Users\XXXX\AppData\Local\Android\Sdk Add enviroment variable ANDROID_SDK_ROOT - set value to desired location Eg: =E:\Android\local\Android\Sdk

For .android folder default path - C:\Users\XXXX\.android Add enviroment variable ANDROID_SDK_HOME- set value to desired location Eg: = E:\Android

For .gradle folder default path - C:\Users\XXXX\.gradle Add enviroment variable GRADLE_USER_HOME - set value to desired location Eg: = E:\Android\.gradle

For .androidstudioXXX

Android Studio-> Help-> Edit Custom Properties Add below lines

idea.config.path=E:/Android/.AndroidStudio4.0/config idea.system.path=E:/Android/.AndroidStudio4.0/system

Add environment variable STUDIO_PROPERTIES - set value to desired location Eg: = E:\Android\idea.properties

Finally don't forget to copy files from the original location to the new location.

Source : https://developer.android.com/studio/command-line/variables Please see the end of the page to know how to add the environment variable on Windows, Mac or Linux

tanni tanna
  • 544
  • 4
  • 12
1

At least for Android 3.0 the steps in the accepted solution are not enough to be able to run the emulators after moving the .android folder (let's say you moved the folder from c:\Users\<username>\.android to I:\Programs\AppData\.android). In addition you need to

  1. Copy (or leave) files adbkey and adbkey.pub in old location (i.e. c:\Users\<username>\.android\adbkey, c:\Users\<username>\.android\adbkey.pub)
  2. Replace the old location path string C:\Users\<username>\ in all .INI files found in the new avd location (i.e. in I:\Programs\AppData\.android\avd) with the new location path string I:\Programme\AppData\
  3. Delete all *.qcow2 files from the new avd location (i:\Programme\AppData\.android\avd) which contain the old location path string c:\Users\<username>\. Check Qcow2-files refer to incorrect/nonexistent base-images for an alternative to delete the *.qcow2 files. If you delete the files all data in the emulator is lost, in this case you will get a clean version of Android, like after a hard reset.
0

To change default .gradle folder using Android Studio 2.2

Open folder of .AndroidStudiox.x (x.x is the version you use) -> config -> options -> gradle.settings.xml file

just right click to open it with wordpad, you should only see 1 option name = serviceDirectoryPath, change the value of that to desired path

remember use / not backward slash \ for folder even in Windows OS

0

I use junction.exe from Sysinternals to make my Java/Android Studio fully "portable" in Windows:

  1. I have "AndroidStudio" installed in a folder "work".
  2. I have "Java\jdk1.8.0_77_x64" in the same "work".
  3. In the same folder "work" I copied the original ".android", ".AndroidStudio2.2" and ".gradle" folders (from C:\Users\<YourProfile>).
  4. Then in the same parent folder "work" I have copied "junction.exe".
  5. Finally in the same "work" I have a batch __init__.bat with content listed below.
  6. Closed Android Studio and deleted original ".android", ".AndroidStudio2.2" and ".gradle" folders (from C:\Users\<YourProfile>).
  7. Run __init__.bat (as Administrator to set also the JAVA_PATH via setx) to create the new junctions then restart Android Studio. This solution works also after I reimage Windows, just have to remeber to run first the mentioned bat...

PS: When I update java or upgrade Android I have to remeber to tweak the bat with the new revision numbers

Content of __init__.bat:

@echo off
@SET mySrcPath=%cd%
@rem echo "%myPath%"
@rem JAVA_HOME = D:\work\Android\Java\jdk1.8.0_77_x64\
@SET myJavaTarget=Java\jdk1.8.0_77_x64\
@SET myJavaPath=%mySrcPath%\%myJavaTarget%
@if not exist "%myJavaPath%" (
    @echo CANNOT FIND myJavaPath = "%myJavaPath%"
    @goto _exit_
 )
@rem echo myJavaPath = "%myJavaPath%"
@setx JAVA_HOME %myJavaPath%

@SET myTargetPath=%USERPROFILE%
@SET myCopy1=.android
@SET myCopy2=.AndroidStudio2.2
@SET myCopy3=.gradle
@SET mySource1="%mySrcPath%\%myCopy1%"
@SET mySource2="%mySrcPath%\%myCopy2%"
@SET mySource3="%mySrcPath%\%myCopy3%"
@SET myTarget1="%myTargetPath%\%myCopy1%"
@SET myTarget2="%myTargetPath%\%myCopy2%"
@SET myTarget3="%myTargetPath%\%myCopy3%"
@rem echo.

@if not exist %mySource1% (
    @echo CANNOT FIND mySource1 = %mySource1%
    @goto _exit_
)

@if not exist %mySource2% (
    @echo CANNOT FIND mySource2 = %mySource2%
    @goto _exit_
)

@if not exist %mySource3% (
    @echo CANNOT FIND mySource3 = %mySource3%
    @goto _exit_
)

@if not exist %myTarget1% (
    @echo creating myTarget1 = %myTarget1% from  mySource1 = %mySource1%
    @junction.exe %myTarget1% %mySource1%
) else (
    @echo myTarget1 = %myTarget1% ALREADY EXISTS !!!!!!
)

@if not exist %myTarget2% (
    @echo creating myTarget2 = %myTarget2% from  mySource2 = %mySource2%
    @junction.exe %myTarget2% %mySource2%
) else (
    @echo myTarget2 = %myTarget2% ALREADY EXISTS !!!!!!
)

@if not exist %myTarget3% (
    @echo creating myTarget3 = %myTarget3% from  mySource3 = %mySource3%
    @junction.exe %myTarget3% %mySource3%
) else (
    @echo myTarget3 = %myTarget3% ALREADY EXISTS !!!!!!
)


:_exit_

@echo exiting...
@pause
user2380383
  • 174
  • 1
  • 8