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

后端 未结 30 3706
星月不相逢
星月不相逢 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 04:54

    There is NO NEED to add to the source control any of the following:

    .idea/
    .gradle/
    *.iml
    build/
    local.properties
    

    So you can configure hgignore or gitignore accordingly.

    The first time a developer clones the source control can go:

    1. Open Android Studio
    2. Import Project
    3. Browse for the build.gradle within the cloned repository and open it

    That's all

    PS: Android Studio will then, through maven, get the gradle plugin assuming that your build.gradle looks similar to this:

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.12.2'
        }
    }
    
    allprojects {
        repositories {
            mavenCentral()
        }
    }
    

    Android studio will generate the content of .idea folder (including the workspace.xml, which shouldn't be in source control because it is generated) and the .gradle folder.

    This approach is Eclipse-friendly in the way that the source control does not really know anything about Android Studio. Android Studio just needs the build.gradle to import a project and generate the rest.

提交回复
热议问题