I migrated my project to Androidx and every time I run my project I keep getting this error that says class BuildConfig is public, should be declared in a file named BuildConfig.java. I know that the cause of my is that every time I build my project my java BuildConfig class keeps getting duplicated. Which gives it a name such as BuildConfig1, BuildConfig2 etc.. I constantly have to keep deleting it and rerunning my project in order to compile this is really annoying does anyone know the cause of this and perhaps a fix? This is my BuildConfig class
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.examp.smartshop";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
}
In recent versions of the Android Developer Tools (ADT) for Eclipse, there's a class called BuildConfig which is automatically generated by the build. This class is updated automatically by Android's build system (like the R class), and it contains a static final boolean called DEBUG, which is normally set to true.
BuildConfig is generated as a Java file. But having a module with mixed Java & Kotlin code impacts on build speed.
or
or
Vote If it works.
Happy coding.
Thanks.
Under the project search for a folder named ".gradle" and while at it search for another under the 'app' folder named "build". Delete the two folders and run your app. It will solve the issue. See this
The error arises as a result of duplication of files hence Android Studio is unable to determine which files to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With