I am moving an old project which runs in it's original project. But, it's gradle has been giving me issues in a new project. The issue is that my gradle task is not recognized by the preBuild call.
I have tried turning them into references with 'copyAppFiles' or directly naming them without single quotes.
Build file 'C:\Users\ZBC\AndroidStudioProjects\MyYapApp\app\build.gradle' line: 88
A problem occurred evaluating project ':app'.
> Could not get unknown property 'copyAppFiles' for project ':app' of type org.gradle.api.Project.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
...
Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'copyAppFiles' for project ':app' of type org.gradle.api.Project.
...
at build_9ohkvz8w7llkrdjeut3507o3h.run(C:\Users\ZBC\AndroidStudioProjects\MyYapApp\app\build.gradle:88)
My Gradle file
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.squareup.sqldelight'
}
android {
defaultConfig {
compileSdkVersion 29
applicationId setPropertyValue('applicationId', 'com.flicast.jw')
targetSdkVersion setPropertyValue('targetSdkVersion', 29)
}
buildTypes {
release {...
}
debug {
debuggable true
resValue "bool", "DEBUG", "true"
}
}
//list flavorDimensions in override priority order
flavorDimensions 'platform', 'theme'
//assign each productFlavor a corresponding flavorDimension
productFlavors {
mobile {
dimension 'platform'
minSdkVersion setPropertyValue('mobileMinSdkVersion', 22)
}
light {
dimension 'theme'
}
dark {
dimension 'theme'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
api project(':xyzacore-android')
api project(':app-bridge')
}
task applyAppFiles {
if (!fileTree('../../app-config/src').isEmpty()) {
//copy app-config files to jw-app/src
task copyAppFiles(type: Copy) { //<-------------
from ("../../app-config/src") {
//exclude ""
}
into "src"
}
}
}
def setPropertyValue(parameterName, defaultValue) {
if (rootProject.ext[parameterName]) {
return rootProject.ext[parameterName]
} else {
return defaultValue
}
}
preBuild.dependsOn(copyAppFiles) //<----------------
preBuild.dependsOn(applyAppFiles)
Top level gradle settings include
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.squareup.sqldelight:gradle-plugin:1.2.1"
Project structure settings are
Gradle Plugin Version 3.6.1
Gradle Version 6.3
Any help would be useful.