AndroidStudio configuration and use of SVN

Install SVN


  1. svn download : https://tortoisesvn.net/downloads.html

  2. svn installation : It should be noted that the command line function needs to be installed.

  3. svn note :

    3.1. You need to restart the computer, and then the various menus of svn will appear after right-clicking.
    3.2. If you open the TotoseSVN client directly, the following prompt will appear:

     tortoisesvn is a shell extension
     that means it is integrated into the windows explorer.
     to use tortoisesvn please open the explorer and right-click on 
     any folder you like to bring up the context menu where you will find all tortoisesvn commands.
          
          
    • 1
    • 2
    • 3
    • 4

    Therefore, svn does not run directly as a client and needs to operate on files.


The use of SVN on AndroidStudio


1. AndroidStudio configure svn:

Steps: Open Android Studio–>File–>Setting–>Version Control–>Subversion

write picture description here

Configure svn path: Add svn.exe to Use Command Line Client in the above figure, the default path of svn C:\Program Files\TortoiseSVN\bin\svn.exe.

If svn.exe does not exist, the command line function is not installed when TotoseSVN is installed and needs to be reinstalled.

2. Android Studio adds ignore files and uploads the project to svn:

  • Ignored files need to be added before uploading the project to svn
    Steps: Open Android Studio–>File–>Setting–>Version Control–>Ignored Files–Add ignored files

    androidStudio provides three options to ignore rules:

     Ignore specified file:忽略指定文件
     Ignore all files under:忽略文件夹下所有文件
     Ignore all files mathching: 忽略符合匹配规则的文件。
          
          
    • 1
    • 2
    • 3

    File ignore rules in SVN:.ide文件 、 .gradle文件 、 所有的build文件(包含module中build) 、 所有的.iml文件 、local.properties 文件。

    Add the ignore files in turn, as shown in the following figure:

    write picture description here

    In addition, there is also a way to add ignore files through the .ignore plugin .
    Steps: File→Settings→Plugins→Browse repositories->Search.ignore->After installation, restart AS->Handwriting ignore file rules.
    The .gitignore file appears in the final project (Project) as shown below:

    write picture description here

  • Android studio uploads the project to svn for association :

    Steps: VCS->Import into Version Control->Import into Subversion (there is no Share Project (Subversion) in androidStudio 2.1.1) –> In the Import into Subversion pop-up window, click + –> Create a new warehouse, fill in the svn server path , select the uploaded project (Project instead of a single Moudle), all the way to next.

    write picture description here

    Import into Subversion process description:

    First import the local code into the SVN server. But SVN doesn't link to local code. Therefore, the code on the svn server needs to be updated, that is, the following steps of AndroidStudio to check out the project from svn in the steps. In this way, the association between the local project and the SVN server can be completed, and normal development can be achieved.

3. AndroidStudio checks out the project from the SVN server:

  • The first way: file–>project from verson controll–>subvsersion–>select the path of the project to be checked out from the Repostory (repository) or add a new project path to be checked out–>check out–>Destionation Directory pop-up window , select the project storage path -> OK, then Android Studio will automatically load the project.

    write picture description here

    write picture description here

    Check the ou project from the SVN server to the local path, and the association is successfully established as shown in the following figure:

    write picture description here

  • The second way: CVS–>Check from Verson Controll–>subversion–>Select repository path–>import:

    Click yes to open. After importing the project, you will be asked twice if *iml should be added to version control, just select no.

    After clicking yes, you may encounter the Import project form Gradle pop-up window when importing other projects. You need to select UseLocal gradle distribution -> select the path to install the gradle plugin in androidstudio in Gradle Home. here is E:\AndroidStudio\studio\plugins\gradle

    Then it prompts:

    the project is using an unsupported version of gradle. please point to a supported Gradle version in the project's Gradle.
    
    The project is using an unsupported version of Gradle.
    Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.) 
    com.intellij.openapi.externalSystem.model.ExternalSystemException: The project is using an unsupported version of Gradle.
    Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.) 
          
          
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    Reason: Gradle version is too new
    Solution :

    1. AS to download the supported Gradle version by yourself.
    2. First copy the project, and then import the project through AS (curve to save the country).
    3. Import other Gradles:

      C:\Users\xxxx.gradle\wrapper\dists\gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo\gradle-1.12

    Then it reported: Plugin with id 'com.android.application' not found.

4. The solution to AndroidStudio svn code conflict:

When the code conflicts, the Files Merged with Conflicts pop-up window will pop up. The left side of the pop-up window is the list of conflicts, and the right side is the merge method, Accept Yours (using your own code as the merged code), Accept Theirs (accepting the code on the svn server), Merge (merging the two).

write picture description here

Best solution: Select Merge -> Merge Control window.
Description of the merged pop-up window: There are three sub-view parts, the leftmost view is the native code, that is, its own code. The intermediate view is the view displayed by the merged code. On the far right is the code view on svn.
Merging method: Click the arrow to add the conflicting code on both sides to the merge area in the middle, and click the cross to identify which piece of code to abandon. After all conflicts are processed, the merge is successful.

write picture description here

5. AndroidStudio browses the project folder on the SVN server:

Steps: Vcs–>Browse VS Repository–>Browse Subversion Repository.

write picture description here

The SVN Repository window will display a list of projects:

write picture description here

6. Color description in the project after SVN association:

  1. Red file: The file in svn is not added, you can right-click –> subversion-add to svn
  2. Green file: associated with svn, but modified and not submitted. You can right click -> subversion-commit file
  3. Blue file: Modified by multiple people, it needs to be downloaded and then uploaded after mergc. You can also lock (subversion-lock) first. After the modification is completed, cmomit submits it, and it will be automatically unlocked.

7. SVN to create a branch

Steps: Right-click on the project (Project) -> SubVersion -> Branch or Tag
-> pop up Create Branch or Tag pop-up window -> Base URL select branch path (select in the rightmost selection path pop-up window in the same peer) -> Comment –> OK.

write picture description here

Operation of comparing projects: Right-click on the project->SubVersion->Compare With branch... Compare and merge.

8. SVN restore repository file

After the file is modified, it is found that the modification is invalid, and the content of the last version of the repository needs to be restored. Right-click the selected file, select Subversion, and then select Reset, that is, the version in the repository is returned.

9. Some svn operational terms:

  1. Auto-update after commit : commit after automatic upgrade

  2. keep files locked : lock the files, I think this should only allow you to modify functions that other developers cannot modify, before you commit: before commit

  3. Reformat code: reformat code

  4. Rearrange code: Rearrange the code

  5. Optimize imports: optimize imports

  6. Perform code analysis: perform code analysis [default selection]

  7. Check TODO(show all): Detect code that needs to be modified [show all default choices]

  8. clean up: clear all

  9. Update copyright: Update copyright

PS: For this article, search and refer to many excellent tutorials through Zhihu, Du Niang, Google and other methods. The resources are as follows.

Resource reference:

                    <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/production/markdown_views-ea0013b516.css">
                        </div>

Install SVN


  1. svn download : https://tortoisesvn.net/downloads.html

  2. svn installation : It should be noted that the command line function needs to be installed.

  3. svn note :

    3.1. You need to restart the computer, and then the various menus of svn will appear after right-clicking.
    3.2. If you open the TotoseSVN client directly, the following prompt will appear:

     tortoisesvn is a shell extension
     that means it is integrated into the windows explorer.
     to use tortoisesvn please open the explorer and right-click on 
     any folder you like to bring up the context menu where you will find all tortoisesvn commands.
        
        
    • 1
    • 2
    • 3
    • 4

    Therefore, svn does not run directly as a client and needs to operate on files.


The use of SVN on AndroidStudio


1. AndroidStudio configure svn:

Steps: Open Android Studio–>File–>Setting–>Version Control–>Subversion

write picture description here

Configure svn path: Add svn.exe to Use Command Line Client in the above figure, the default path of svn C:\Program Files\TortoiseSVN\bin\svn.exe.

If svn.exe does not exist, the command line function is not installed when TotoseSVN is installed and needs to be reinstalled.

2. Android Studio adds ignore files and uploads the project to svn:

  • Ignored files need to be added before uploading the project to svn
    Steps: Open Android Studio–>File–>Setting–>Version Control–>Ignored Files–Add ignored files

    androidStudio provides three options to ignore rules:

     Ignore specified file:忽略指定文件
     Ignore all files under:忽略文件夹下所有文件
     Ignore all files mathching: 忽略符合匹配规则的文件。
        
        
    • 1
    • 2
    • 3

    File ignore rules in SVN:.ide文件 、 .gradle文件 、 所有的build文件(包含module中build) 、 所有的.iml文件 、local.properties 文件。

    Add the ignore files in turn, as shown in the following figure:

    write picture description here

    In addition, there is also a way to add ignore files through the .ignore plugin .
    Steps: File→Settings→Plugins→Browse repositories->Search.ignore->After installation, restart AS->Handwriting ignore file rules.
    The .gitignore file appears in the final project (Project) as shown below:

    write picture description here

  • Android studio uploads the project to svn for association :

    Steps: VCS->Import into Version Control->Import into Subversion (there is no Share Project (Subversion) in androidStudio 2.1.1) –> In the Import into Subversion pop-up window, click + –> Create a new warehouse, fill in the svn server path , select the uploaded project (Project instead of a single Moudle), all the way to next.

    write picture description here

    Import into Subversion process description:

    First import the local code into the SVN server. But SVN doesn't link to local code. Therefore, the code on the svn server needs to be updated, that is, the following steps of AndroidStudio to check out the project from svn in the steps. In this way, the association between the local project and the SVN server can be completed, and normal development can be achieved.

3. AndroidStudio checks out the project from the SVN server:

  • The first way: file–>project from verson controll–>subvsersion–>select the path of the project to be checked out from the Repostory (repository) or add a new project path to be checked out–>check out–>Destionation Directory pop-up window , select the project storage path -> OK, then Android Studio will automatically load the project.

    write picture description here

    write picture description here

    Check the ou project from the SVN server to the local path, and the association is successfully established as shown in the following figure:

    write picture description here

  • The second way: CVS–>Check from Verson Controll–>subversion–>Select repository path–>import:

    Click yes to open. After importing the project, you will be asked twice if *iml should be added to version control, just select no.

    After clicking yes, you may encounter the Import project form Gradle pop-up window when importing other projects. You need to select UseLocal gradle distribution -> select the path to install the gradle plugin in androidstudio in Gradle Home. here is E:\AndroidStudio\studio\plugins\gradle

    Then it prompts:

    the project is using an unsupported version of gradle. please point to a supported Gradle version in the project's Gradle.
    
    The project is using an unsupported version of Gradle.
    Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.) 
    com.intellij.openapi.externalSystem.model.ExternalSystemException: The project is using an unsupported version of Gradle.
    Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.) 
        
        
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    Reason: Gradle version is too new
    Solution :

    1. AS to download the supported Gradle version by yourself.
    2. First copy the project, and then import the project through AS (curve to save the country).
    3. Import other Gradles:

      C:\Users\xxxx.gradle\wrapper\dists\gradle-1.12-all\2apkk7d25miauqf1pdjp1bm0uo\gradle-1.12

    Then it reported: Plugin with id 'com.android.application' not found.

4. The solution to AndroidStudio svn code conflict:

When the code conflicts, the Files Merged with Conflicts pop-up window will pop up. The left side of the pop-up window is the list of conflicts, and the right side is the merge method, Accept Yours (using your own code as the merged code), Accept Theirs (accepting the code on the svn server), Merge (merging the two).

write picture description here

Best solution: Select Merge -> Merge Control window.
Description of the merged pop-up window: There are three sub-view parts, the leftmost view is the native code, that is, its own code. The intermediate view is the view displayed by the merged code. On the far right is the code view on svn.
Merging method: Click the arrow to add the conflicting code on both sides to the merge area in the middle, and click the cross to identify which piece of code to abandon. After all conflicts are processed, the merge is successful.

write picture description here

5. AndroidStudio browses the project folder on the SVN server:

Steps: Vcs–>Browse VS Repository–>Browse Subversion Repository.

write picture description here

The SVN Repository window will display a list of projects:

write picture description here

6. Color description in the project after SVN association:

  1. Red file: The file in svn is not added, you can right-click –> subversion-add to svn
  2. Green file: associated with svn, but modified and not submitted. You can right click -> subversion-commit file
  3. Blue file: Modified by multiple people, it needs to be downloaded and then uploaded after mergc. You can also lock (subversion-lock) first. After the modification is completed, cmomit submits it, and it will be automatically unlocked.

7. SVN to create a branch

Steps: Right-click on the project (Project) -> SubVersion -> Branch or Tag
-> pop up Create Branch or Tag pop-up window -> Base URL select branch path (select in the rightmost selection path pop-up window in the same peer) -> Comment –> OK.

write picture description here

Operation of comparing projects: Right-click on the project->SubVersion->Compare With branch... Compare and merge.

8. SVN restore repository file

After the file is modified, it is found that the modification is invalid, and the content of the last version of the repository needs to be restored. Right-click the selected file, select Subversion, and then select Reset, that is, the version in the repository is returned.

9. Some svn operational terms:

  1. Auto-update after commit : commit after automatic upgrade

  2. keep files locked : lock the files, I think this should only allow you to modify functions that other developers cannot modify, before you commit: before commit

  3. Reformat code: reformat code

  4. Rearrange code: Rearrange the code

  5. Optimize imports: optimize imports

  6. Perform code analysis: perform code analysis [default selection]

  7. Check TODO(show all): Detect code that needs to be modified [show all default choices]

  8. clean up: clear all

  9. Update copyright: Update copyright

PS: For this article, search and refer to many excellent tutorials through Zhihu, Du Niang, Google and other methods. The resources are as follows.

Resource reference:

                    <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/production/markdown_views-ea0013b516.css">
                        </div>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324641516&siteId=291194637