-1

Android Studio 3.5

In app/build.gradle :

   buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            configBuildType(delegate, RELEASE_APP_NAME)
        }
        debug {
            configBuildType(delegate, DEBUG_APP_NAME, DEBUG_APP_VERSION)
        }
    }


    def configBuildType(buildType, appName, appVersion) {
        buildType.resValue("string", "application_name", appName)
        buildType.buildConfigField("String", "APP_VERSION", appVersion)
     }

Nice it's work.

But I how I can convert my custom task to build.gradle.kts ?

Santanu Sur
  • 10,997
  • 7
  • 33
  • 52
Alexei
  • 14,350
  • 37
  • 121
  • 240

1 Answers1

0

You can use this snippet:

android {
    buildTypes {
        getByName("debug") {
            configBuildType(this, DEBUG_APP_NAME, DEBUG_APP_VERSION)
        }
    }
}

fun configBuildType(buildType: com.android.build.gradle.internal.dsl.BuildType, appName: String, appVersion: String) {
    buildType.resValue("string", "application_name", appName)
    buildType.buildConfigField("String", "APP_VERSION", appVersion)
}
Maksym S.
  • 141
  • 4