How to define common android properties for all modules using gradle

前端 未结 8 1966
走了就别回头了
走了就别回头了 2020-12-04 14:20

I create a simple project in AndroidStudio with a few modules. Each module\'s gradle script contains the following code:

android {
    compileSdkVersion 18
          


        
相关标签:
8条回答
  • 2020-12-04 14:55

    Create a custom property for your project. To set a single property use:

    project.ext.compileSdkVersion = 21
    

    to set multiple properties use:

    project.ext {
        compileSdkVersion = 21
        buildToolsVersion = "21.0.1"
        targetSdkVersion = 21
    }
    
    0 讨论(0)
  • 2020-12-04 14:55

    There is a new way simpler method, in the updated Android Studio. You have a file named "gradle.properties" in the top project hierarchy exactly for that. Simply define your parameters there:

    common_parameter='I am common"
    

    And use it in the modules' gradle files (build.gradle) as such:

    module_parameter = common_parameter
    

    That's it.

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