gradle-buildconfig-plugin
gradle-buildconfig-plugin copied to clipboard
Can not find BuildConfig in a java file
Can not find BuildConfig in a java file.
plugins { id 'java' id 'de.fuerstenau.buildconfig' version '1.1.8' }
version '0.1'
sourceCompatibility = 1.8
repositories { mavenCentral() }
test { useTestNG() }
buildConfig { buildConfigField 'String', 'MY_STR_FIELD', '"my message to the app"' }
dependencies { compile group: 'org.testng', name: 'testng', version: '6.14.3' compile group: 'io.appium', name: 'java-client', version: '6.1.0' } apply plugin: 'idea'
If anyone has a solution please suggest this problem :(
Just run gradle compileBuildConfig in your terminal of course inside the project
It's here.
I have had this problem too. Just rebuild your project in IDE. Build > Rebuild Project
If the problem is that the file was not created, just run gradle compileBuildConfig or build, as other already answered.
If the problem is that the file was created but your IDE is not recognizing it, if your IDE is IntelliJ adding this to your gradle might help:
build.gradle.kts (it's similar in groovy)
plugins {
...
kotlin("jvm") version "1.6.20"
id("idea")
}
// For Kotlin (similar for Java)
kotlin {
sourceSets {
main {
this.kotlin.srcDir("$buildDir/gen/buildconfig/src/")
}
}
}
idea {
module {
// Tell idea to mark the folder as generated sources
generatedSourceDirs.add(File("$buildDir/gen/buildconfig/src/"))
}
}