Gradle build for set of Android projects (including libraries)

前端 未结 2 454
深忆病人
深忆病人 2021-01-15 00:36

I have 2 Android apps with 5 Android modules (Android library project). Total 7 Eclipse projects. I want to enable Gradle build for them. I added build.gradle i

2条回答
  •  醉梦人生
    2021-01-15 01:16

    You can use your build.gradle in root, or you can define some values in gradle.properties in root folder to achieve your scope.

    For example:

    root/build.gradle:

    ext {
        compileSdkVersion = 19
        buildToolsVersion = "19.0.3"
    }
    

    module/build.gradle:

    android {
        compileSdkVersion rootProject.ext.compileSdkVersion
        buildToolsVersion rootProject.ext.buildToolsVersion
    }
    

    OR using properties

    root/gradle.properties:

    VERSION_NAME=1.0.1
    VERSION_CODE=11
    

    module/build.gradle:

    android {
    
        defaultConfig {
            versionName project.VERSION_NAME
            versionCode Integer.parseInt(project.VERSION_CODE)
    
        }
    

提交回复
热议问题