Android BuildConfig.VERSION_ Name returned null?

I want to display my version name on the login screen, but it always returns null. I defined my versionname in the gradle build of my application, as follows:

    defaultConfig {
    applicationId "com.maplesyrupindustries.j.airportmeet"
    minSdkVersion 19
    targetSdkVersion 24
    versionCode 7
    versionName "1.0.6"
    multiDexEnabled true
}

I call it in the login onCreate:

    String build = BuildConfig.VERSION_NAME;
    Log.e(TAG,BuildConfig.VERSION_NAME);
    tvVersion.setText("Alpha " + build);

However, the build string is always empty. What gives?

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>