Access Versionname In Build.gradle
Is there a way to access versionName in my build.gradle from xml? I would like to set a TextView's text with this value. Or maybe declare a string with the version in strings.xml a
Solution 1:
You can use BuildConfig
class for this. For example:
TextViewmTv= (TextView) findViewById(R.id.mTv);
mTv.setText(BuildConfig.VERSION_NAME);
or
Toast.makeText(this, BuildConfig.VERSION_NAME, Toast.LENGTH_SHORT).show();
Post a Comment for "Access Versionname In Build.gradle"