targetSdkVersion gradle strange value

前端 未结 1 2060
难免孤独
难免孤独 2021-01-24 06:06

So, I cloned this project from Github and while going through its build.gradle, I found this strange configuration, particularly for targetSdkVersion.

相关标签:
1条回答
  • 2021-01-24 06:29

    why would someone use this property?

    • The main purpose behind to use this property To Configure all variables for Android project modules in one place
    • so changing it in one place will effect in whole project

    how do I find out what version it is?

    • it will be available in gradle.properties or build.gradle in file

    have a look in Build.Gradle file of CallRecorder of that project

    SAMPLE

    Here is the good article on it Configure variables for all Android project modules in one place

    gradle.properties

    # Project-wide Gradle settings.
    # IDE (e.g. Android Studio) users:
    # Gradle settings configured through the IDE *will override*
    # any settings specified in this file.
    # For more details on how to configure your build environment visit
    # http://www.gradle.org/docs/current/userguide/build_environment.html
    # Specifies the JVM arguments used for the daemon process.
    # The setting is particularly useful for tweaking memory settings.
    org.gradle.jvmargs=-Xmx1536m
    android.useAndroidX = true
    android.enableJetifier = false
    
    #gradle.properties
    myTargetSdkVersion=27
    myCompileSdkVersion=27
    # When configured, Gradle will run in incubating parallel mode.
    # This option should only be used with decoupled projects. More details, visit
    # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
    # org.gradle.parallel=true
    

    than use in your Build.Gradle

    android {
        compileSdkVersion project.myTargetSdkVersion.toInteger()
        defaultConfig {
            applicationId "com.example.nilesh.myapplication"
            minSdkVersion project.myMinSdkVersion.toInteger()
            targetSdkVersion project.myTargetSdkVersion.toInteger()
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            targetCompatibility 1.8
            sourceCompatibility 1.8
        }
    }
    
    0 讨论(0)
提交回复
热议问题