Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppVersion.java uses or overrides a deprecated API #133

Open
templatetuners opened this issue Oct 19, 2022 · 1 comment
Open

AppVersion.java uses or overrides a deprecated API #133

templatetuners opened this issue Oct 19, 2022 · 1 comment

Comments

@templatetuners
Copy link

cordova\AppVersion.java uses or overrides a deprecated API

cordova 11.0.0

@MrRotella
Copy link

this plugin use a deprecated api to retrieve the versionCode. From Api level 28 versionCode was replaced by getLongVersionCode method. To avoid this issue in the AppVersion.java yuo need to:

  • import android.os.Build;
  • if (action.equals("getVersionCode")) { PackageManager packageManager = this.cordova.getActivity().getPackageManager(); if(android.os.Build.VERSION.SDK_INT>=28) { callbackContext.success(packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), 0).getLongVersionCode()); } else { callbackContext.success(packageManager.getPackageInfo(this.cordova.getActivity().getPackageName(), 0).versionCode); } return true; }

Hope this may help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants