Reputation: 241
In my app I need to fetch the app version code and name so I was using below statement.
obj.setCurrentVersion("APP " +
String.valueOf(BuildConfig.VERSION_NAME));
It was working fine and returns correct result. But now it's return empty string once i checked BuildConfig class all the values are empty.
public final class BuildConfig {
public static final boolean DEBUG = false;
public static final java.lang.String APPLICATION_ID = "androidx.multidex";
public static final java.lang.String BUILD_TYPE = "release";
public static final java.lang.String FLAVOR = "";
public static final int VERSION_CODE = -1;
public static final java.lang.String VERSION_NAME = "";
public BuildConfig() { /* compiled code */ }
}
Build_gradle file
apply plugin: 'com.android.application'
android {
signingConfigs {
config {
}
}
compileSdkVersion 28
defaultConfig {
applicationId "com.app.application"
minSdkVersion 21 //21
targetSdkVersion 28
versionCode 16 //15
versionName "2.0.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Why is that happening and how to fix it?
Upvotes: 1
Views: 1313
Reputation: 18416
You import wrong BuildConfig file
Remove your BuildConfig import & re-import your app module BuildConfig
Upvotes: 2