gradle-buildconfig-plugin icon indicating copy to clipboard operation
gradle-buildconfig-plugin copied to clipboard

Can not find BuildConfig in a java file

Open marcogalicia25 opened this issue 6 years ago • 5 comments

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'

marcogalicia25 avatar Jul 13 '18 00:07 marcogalicia25

If anyone has a solution please suggest this problem :(

adiaholic avatar Dec 20 '18 13:12 adiaholic

Just run gradle compileBuildConfig in your terminal of course inside the project

marcogalicia25 avatar Dec 20 '18 17:12 marcogalicia25

It's here.

image

wonsuc avatar Sep 27 '19 05:09 wonsuc

I have had this problem too. Just rebuild your project in IDE. Build > Rebuild Project

YuriyBergrin avatar Aug 18 '20 14:08 YuriyBergrin

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/"))
    }
}

allanveloso avatar Apr 30 '22 21:04 allanveloso