Is it possible to allocate these folders in another place?

后端 未结 6 473
甜味超标
甜味超标 2020-11-30 18:27

I am installing Android Studio and I have by default the path C:\\Users\\Administrator\\AppData\\Local\\Android\\sdk to set my SDK. If

6条回答
  •  借酒劲吻你
    2020-11-30 19:02

    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
    

提交回复
热议问题