Sam
07/01/2022, 10:49 AMdef applyAndroid(project) {
project.android {
compileSdkVersion compileVersion
defaultConfig {
minSdkVersion minVersion
targetSdkVersion compileVersion
versionCode verCode
versionName verName
testInstrumentationRunner testRunner
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
kotlinOptions {
jvmTarget = "1.8"
// useIR = true
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
freeCompilerArgs += "-Xjvm-default=all"
}
testOptions.unitTests {
includeAndroidResources = true
}
buildFeatures {
aidl = false
renderScript = false
resValues = false
shaders = false
}
}
}
I have a limitation in the Project class, I can't find an android() methodVampire
07/01/2022, 10:51 AMandroid
in Kotlin DSL is a type-safe accessor that is only generated if you apply the corresponding plugin in the same script using the plugins { ... }
DSL.
So in your convention plugin you either have to also apply the corresponding plugin which makes sense as you also want to configure it, or you need to do it without the sugar of the generated accessor and do something like configure<AndroidExtensionOrHoweverTheClassNameIs>() { ... }
Sam
07/01/2022, 10:57 AMVampire
07/01/2022, 12:15 PMapply false
is not applying, it is just adding to class path, so no accessors would be generated.
And besides that, as I said it has to be in the script where the code is to get the accessors in the right scope.