Collaborative use of Android Studio and SVN version of the Program Guide _android

Source: Internet
Author: User
Tags svn svn client svn update tortoisesvn

Androidstudio SVN Installation and usage of the other IDE I used to have a big difference, feel special trouble, online information is very small, seemingly now Git more popular, before the use of GitHub but he can only be open source project free, the following summary of the recent installation and use SVN A summary of some of the experiences:
If you encounter unexpected situations such as ignore or other settings that are not valid, you can try restarting Androidstudio or performing an SVN update.

First, installation configuration:
previously used Zendstudio and so on are directly installed Plug-ins on it, but not here, you need to install the command line function of the SVN client independently, I used the TORTOISESVN, said after 1.7 to support command line mode, I'm using the 1.8.5 version now.
As shown in the figure, the installation must be customized to select command line otherwise it will not be installed

When the installation is complete, open the IDE's setting Configuration panel:

such as the Subersion setting under the Path Version control of the above figure:
Use Command line Client chooses to browse to the Svn.exe file path of your local installation TortoiseSVN, as follows: (Note that there is a browse button at the far right of the input box, it may not appear, the stretching window is visible)

When configured, the installation is complete

Second, import, check out SVN
This is relatively simple:

Under the CVS menu, an Import into Version control selects SVN.
The checkout operation is also similar, and you can check out and build the project from SVN in a new project

In addition: The bottom of the column browse VCS Repository can browse files on a remote SVN server and delete them, and so on

Third, Ignore specifies to ignore files or directories
the Ignore in the Androidstudio Setting panel seems to have little effect,
Let's take a look at the display of neglected directories (darker yellow-green color)

Configuration in Setting, mostly ignored directories and files: (Although the settings here do not work, but set it down)
The system defaults to two or three files and directories that I added myself. Gradle. Idea build Directory I don't think these three directories should follow SVN, everyone's local environment is different at compile time, and I've encountered a library file under build and idea that always conflicts, every Update a lot of times, so get rid of it.

To add an ignore by TortoiseSVN:

For updates and submissions

These two small buttons operate very well, the green up is commit, and the blue down is update.

Iv. Use the Gradle plugin to automatically fill in the SVN number and publish (copy) to the specified directory
Gradle is a dependency management tool, and its GitHub project address is as follows:
Https://github.com/Goddchen/Android-Gradle-Examples/tree/master/Gradle%20Library%20Projects
Installation layout is very convenient, here is no longer said, the following we specifically look at
SVN number:

1, classpath increase dependence:

Classpath group: ' Org.tmatesoft.svnkit ', Name: ' Svnkit ', version: ' 1.8.11 ' 

(You can find the latest version)


2, in the main project (App module directory) Build.gradle under the increase:

Android {...} 
 
Def getsvnrevision () { 
  isvnoptions options = Svnwcutil.createdefaultoptions (true); 
  Svnclientmanager Clientmanager = svnclientmanager.newinstance (options); 
  Svnstatusclient statusclient = Clientmanager.getstatusclient (); 
  Svnstatus status = Statusclient.dostatus (ProjectDir, false); 
  Svnrevision revision = Status.getrevision (); 
  def svnnum = Revision.getnumber (); 
  println ("SVN version:" + svnnum); 
  println ("============"); 
  return svnnum; 
} 

Note that revision must be updated locally before it can be obtained. There are other data in the status, such as final submissions. You need to change it yourself.

APP Version Number:

The app version number can be defaultconfig directly, but sometimes it's written in manifest. It's not easy to forget.

Def getvername () { 
  String manifesttext = File ("Androidmanifest.xml"). GetText (); 
  def matcherversion = Pattern.compile ("android:versionname=\" ([\\d.] +). *\ ""). Matcher (Manifesttext); 
  if (Matcherversion.find ()) { 
    def vername = Matcherversion.group (1); 
    println ("============"); 
    println ("App version:" + vername); 
    return vername; 
  } else { 
    throw new gradleexception (' not find versionname in Androidmanifest '); 
  } 
 

Note that the androidmanifest path is relative to the current build.gradle, and the standard as creation is in Src/main/androidmanifest.xml

Use can be directly =, or with ${getvername ()}

Post-Compile Output path:

There are many ways to do this, one is a build copy, one is to directly modify the output path of the variants, here for the first time to provide the following:

Buildtypes {release 
  { 
    //... 
    .. Applicationvariants.all {Variant-> 
      if (' Release '. Equals (Variant.buildType.name)) {// 
        only release Variant.outputs.each {output-> 
          def targetDir = "D:/app";//target path 
 
          output.outputfile = new File (targetdir,
   
     "App_${getvername ()}_${getsvnrevision ()}.apk"); 
          println (Output.outputfile)}}}} 
 

   

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.