How to get the build/version number of your Android application?

前端 未结 30 1759
刺人心
刺人心 2020-11-22 11:00

I need to figure out how to get or make a build number for my Android application. I need the build number to display in the UI.

Do I have to do something with

30条回答
  •  清酒与你
    2020-11-22 11:34

    Useful for build systems: there is a file generated with your apk called output.json which contains an array of information for each generated APK, including the versionName and versionCode.

    eg

    [
        {
            "apkInfo": {
                "baseName": "x86-release",
                "enabled": true,
                "filterName": "x86",
                "fullName": "86Release",
                "outputFile": "x86-release-1.0.apk",
                "splits": [
                    {
                        "filterType": "ABI",
                        "value": "x86"
                    }
                ],
                "type": "FULL_SPLIT",
                "versionCode": 42,
                "versionName": "1.0"
            },
            "outputType": {
                "type": "APK"
            },
            "path": "app-x86-release-1.0.apk",
            "properties": {}
        }
    ]
    

提交回复
热议问题