What should be in my .gitignore for an Android Studio project?

后端 未结 30 3382
星月不相逢
星月不相逢 2020-11-22 04:23

What files should be in my .gitignore for an Android Studio project?

I\'ve seen several examples that all include .iml but IntelliJ docs sa

相关标签:
30条回答
  • 2020-11-22 05:00

    It's best to add up the .gitignore list through the development time to prevent unknown side effect when Version Control won't work for some reason because of the pre-defined (copy/paste) list from somewhere. For one of my project, the ignore list is only of:

    .gradle
    .idea
    libs
    obj
    build
    *.log
    
    0 讨论(0)
  • 2020-11-22 05:02

    Basically any file that is automatically regenerated.

    A good test is to clone your repo and see if Android Studio is able to interpret and run your project immediately (generating what is missing).
    If not, find what is missing, and make sure it isn't ignored, but added to the repo.

    That being said, you can take example on existing .gitignore files, like the Android one.

    # built application files
    *.apk
    *.ap_
    
    # files for the dex VM
    *.dex
    
    # Java class files
    *.class
    
    # generated files
    bin/
    gen/
    
    # Local configuration file (sdk path, etc)
    local.properties
    
    # Eclipse project files
    .classpath
    .project
    
    # Proguard folder generated by Eclipse
    proguard/
    
    # Intellij project files
    *.iml
    *.ipr
    *.iws
    .idea/
    
    0 讨论(0)
  • 2020-11-22 05:04

    I use this .gitignore. I found it at: http://th4t.net/android-studio-gitignore.html

    *.iml
    *.iws
    *.ipr
    .idea/
    .gradle/
    local.properties
    
    */build/
    
    *~
    *.swp
    
    0 讨论(0)
  • 2020-11-22 05:04

    Compilation:

    #built application files
    *.apk
    *.ap_
    
    # files for the dex VM
    *.dex
    
    # Java class files
    *.class
    
    # generated files
    bin/
    gen/
    
    # Gradle files
    .gradle/
    build/
    /*/build/
    
    # Local configuration file (sdk path, etc)
    local.properties
    
    # Proguard folder generated by Eclipse
    proguard/
    
    # Log Files
    *.log
    
    # Windows thumbnail db
    Thumbs.db
    
    # OSX files
    .DS_Store
    
    # Eclipse project files
    .classpath
    .project
    
    # Android Studio
    *.iml
    .idea
    #.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
    .gradle
    build/
    
    # Intellij project files
    *.iml
    *.ipr
    *.iws
    .idea/
    
    0 讨论(0)
  • 2020-11-22 05:05

    As of Android Studio 0.8.4 .gitignore file is generated automatically when starting new project. By default it contains:

    .gradle
    /local.properties
    /.idea/workspace.xml
    /.idea/libraries
    .DS_Store
    /build
    
    0 讨论(0)
  • 2020-11-22 05:05

    To circumvent the import of all files, where Android Studio ignores the "Ignored Files" list, but still leverage Android Studio VCS, I did the following: This will use the "Ignored Files" list from Android Studio (after import! not during) AND avoid having to use the cumbersome way Tortoise SVN sets the svn:ignore list.

    1. Use the Tortoise SVN repository browser to create a new project folder directly in the repository.
    2. Use Tortoise SVN to checkout the new folder over the top of the folder you want to import. You will get a warning that the local folder is not empty. Ignore the warning. Now you have a versioned top level folder with unversioned content.
    3. Open your project from the local working directory. VCS should now be enabled automatically
    4. Set your file exceptions in File -> Settings -> Version Control -> Ignored Files
    5. Add files to SVN from Android Studio: select 'App' in Project Structure -> VCS -> Add to VCS (this will add all files, except "Ignored Files")
    6. Commit Changes

    Going forward, "Ignored Files" will be ignored and you can still manage VCS from Android Studio.

    Cheers, -Joost

    0 讨论(0)
提交回复
热议问题