How do I get my application Version in Android
This page has a tips on how to do it from java:
PackageManager manager = context.getPackageManager();
PackageInfo info = manager.getPackageInfo(
context.getPackageName(), 0);
String version = info.versionName;
Also, this link has official information on how to properly set up your application versioning.
How to get build and version number of Flutter app
You can use package_info_plus.
The versions are extracted from:
Android:
build.gradle, versionCode and versionName
iOS:
Info.plist, CFBundleVersion
Usage
Add the dependency
- Add this to your package's pubspec.yaml file:
dependencies:
package_info_plus: ^1.0.6
- Import the file into your dart file:
import 'package:package_info_plus/package_info_plus.dart';
- if your method is marked as
async
:
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String appName = packageInfo.appName;
String packageName = packageInfo.packageName;
String version = packageInfo.version;
String buildNumber = packageInfo.buildNumber;
If you don't want to use await/async
:
PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
String appName = packageInfo.appName;
String packageName = packageInfo.packageName;
String version = packageInfo.version;
String buildNumber = packageInfo.buildNumber;
});
How to set build and version number of Flutter app
Setting the version and build number
You can update both the version name and the version code number in the same place in pubspec.yaml. Just separate them with a +
sign. For example:
version: 2.0.0+8
This means
- The version name is
2.0.0
- The version code is
8
This is described in the documentation of a new project (but you might have deleted that if you are working on an old project):
The following defines the version and build number for your application.
A version number is three numbers separated by dots, like 1.2.43
followed by an optional build number separated by a +.
Both the version and the builder number may be overridden in flutter
build by specifying --build-name and --build-number, respectively.
Read more about versioning at semver.org.
version: 1.0.0+1
Re-enabling auto versioning
If your Flutter versioning is not automatically updating anymore, see this answer for how to fix it.
See also:
- How to get build and version number of Flutter app
Get current app's build version - Xamarin.Android
For version name:
Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionName
For version code:
Application.Context.ApplicationContext.PackageManager.GetPackageInfo(Application.Context.ApplicationContext.PackageName, 0).VersionCode
How to change Android version and code version number?
Go in the build.gradle and set the version code and name inside the defaultConfig
element
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
Related Topics
How to Change Fontfamily of Textview in Android
How to Implement Endless List With Recyclerview
Saving and Reading Bitmaps/Images from Internal Memory in Android
How to Draw a Path on a Map Using Kml File
Getting the Absolute File Path from Content Uri For Searched Images
How to Store Image in Sqlite Database
Re-Launch of Activity on Home Button, But...Only the First Time
How to Handle Button Clicks Using the Xml Onclick Within Fragments
Android Accelerometer Accuracy (Inertial Navigation)
Determining the Current Foreground Application from a Background Task or Service
Difference Between Compilesdkversion and Targetsdkversion
How to Make Layout With Rounded Corners..
Android 8.0: Java.Lang.Illegalstateexception: Not Allowed to Start Service Intent
Android Basics: Running Code in the Ui Thread
Can't Find Theme.Appcompat.Light For New Android Actionbar Support