Get Build Version and Name
import com.yourpackage.BuildConfig;
...
int versionCode = BuildConfig.VERSION_CODE;
String versionName = BuildConfig.VERSION_NAME;
Also make sure to specify them in your build.gradle file
instead of the AndroidManifest.xml
defaultConfig {
versionCode 1
versionName "1.0"
}