java - Unable to get version name in code after moving to Gradle -
I have so far taken one of my Android projects to Gradle, and according to the recommendations I All configurations (minimum / maximum sdk, version name / code etc.) have been moved to the Build.gradle file. Now a bug has been told that one customer could see the version name and code inside the product.
After checking this, I came to know that the common method of removing those people is Now I am looking for a way to remove these same values for use in code, but I have not found any reference to this behavior and where (it is not working like this) < / P> All hints, tips or solutions appreciated. Use your version which is defined in the android: versionCode = "" and
android: versionName = ""
tags After deleting
AndroidManifest.xml the values have stopped working. I have verified that these values occur when these are the values.
I had to remove the code used to obtain these values from the package manager, so
try {PackageInfo pInfo = ctx.getPackageManager (). GetPackageInfo () Ctx.getPackageName (), 0); Return pInfo.versionName + "build" + pInfo.versionCode; } Hold (PackageManager.NameNotFoundException e) {e.printStackTrace (); }
build.gradle file
BuildConfig class to get the code:
Log.e (tag, BuildConfig.VERSION_NAME + "build" + build config.VERSION_CODE);
Comments
Post a Comment