Error webview ionic plugin api 30

We are having a problem generating our android ionic application. We need to update the android-targetSdkVersion to 30 and we want to do it without losing the localstorage data. When we run the command:

sudo ionic cordova build android --release --prod

We get this error

	> Task :app:compileReleaseJavaWithJavac FAILED
	…platforms/android/app/src/main/java/com/ionicframework/cordova/webview/ error: package does not exist

	…platforms/android/app/src/main/java/com/ionicframework/cordova/webview/ error: cannot find symbol

  	symbol:   class RequiresApi
  	location: class com.ionicframework.cordova.webview.IonicWebViewEngine.ServerClient
	Note: …/platforms/android/app/src/main/java/com/ionicframework/cordova/webview/ uses or overrides a deprecated API.
	Note: Recompile with -Xlint:deprecation for details.
	2 errors

We currently use the plugin cordova-ionic-webview 2.5.2.

  • Upgrading to version 5.X of the plugin fixes the bug and allows the build to be generated but causes the localstorage to be deleted so it is discarded. (Upgrading from version 2.X to 3.X or higher deletes the localstorage).
  • We opted to comment out the lines that cause this error. That way it does allow to generate the build but it also deletes the localstorage data, which makes us think that the deletion could also be from updating the android-targetSdkVersion.

Given this situation we would like to know if there is a way to update the android-targetSdkVersion to 30 without affecting the localStorage.