SoFunction
Updated on 2025-04-09

The difference between Android SdkVersion and how to obtain version information

1. What is the difference between the four values: minSdkVersion, targetSdkVersion, maxSdkVersion, and compileSdkVersion?

• minSdkVersion, maxSdkVersion is the lowest SDK version and the highest SDK version supported by the project. Before installing apk, the system will judge these two values ​​to determine whether the current system can be installed. Generally, maxSdkVerson will not be set.

• compileSdkVersion is the SDK version at the time of project compile.

• targetSdkVersion will tell the system that this version has been fully tested, so when the program runs on this version of the system, it will not make too many additional compatibility judgments, and the operation efficiency will be higher.

2. Obtain version information

What are the differences and uses of versionName and versionCode?

• android:versionCode: It is mainly used for version upgrades. It is of INT type. The first version is defined as 1 and increments later. In this way, as long as the value is judged, you can determine whether the upgrade is needed. The value will not be displayed to the user.

• android:versionName: This is the version number we often specify. This value is a string that can be displayed to the user.

• versionCode is used to identify the version (upgrade) for the device program. It must be an interger value and an integer, which means how many times the app has been updated can be 1, 2, etc.; versionName is for users to see, and can write 1.1, 1.2, etc.

Or get version information

private void getVersion(){
  PackageManager pm=getPackageManager();
  try{
    PackageInfo info=(getPackageName(),0);
    String versionName=;
    int versionCode=;
  }cache(NameNotFoundException e){
    ();
  }

}

The difference between the above Android SdkVersion and the method of obtaining version information is all the content I share with you. I hope you can give you a reference and I hope you can support me more.