Skip to content

buildVersion is not a string on Android #57

@haileyok

Description

@haileyok

buildVersion is typed as ?string in the JS code.

https://github.com/APSL/react-native-version-number/blob/master/index.js#L7

type VersionObject = {
  appVersion: ?string,
  buildVersion: ?string,
  bundleIdentifier: ?string
};

However, in the Android code, versionCode from PackageInfo is used, which is a Java int

https://developer.android.com/reference/android/content/pm/PackageInfo#versionCode
https://github.com/APSL/react-native-version-number/blob/master/android/src/main/java/com/apsl/versionnumber/RNVersionNumberModule.java#L41

constants.put(APP_BUILD, packageManager.getPackageInfo(packageName, 0).versionCode);

This usually doesn't present itself as a problem, but in some cases - such as when passing this value back across the bridge - there can be problems. Probably would be best to convert it to a string before passing it over the bridge the first time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions