-1

We got mail regarding needs to update android target api level

We are currently on Ionic/ Capacitor platform.

For android app we followed the below step to change api level. From Andorid studio -> variables.gradle file -> Change targetSdkVersion = 33.

Is this the only file where I need to change the versions? Or still there are some places where I need to change version?

Also there is compileSdkVersion Should I also need to change their version to approve apps or make my apps eligible for the below image changes?(My cuurent compileSdkVersion is 31)

When I set the version to 33 it provide me below error. error: cannot find symbol settings.setAppCacheEnabled(true); compileSdkVersion = 33 ionic capacitor

enter image description here

Vaibhav Shah
  • 35
  • 1
  • 5

3 Answers3

2

I use "@capacitor/core": "^3.5.0"

And fix this issue editing

\node_modules\@capacitor\android\capacitor\src\main\java\com\getcapacitor\Bridge.java

Changing this line

settings.setAppCacheEnabled(true)

to

settings.setCacheMode(WebSettings.LOAD_DEFAULT);

1

It is possible that in addition to what the colleague has said, you may need to make more changes to your application. The version of Capacitor has recently been upgraded to version 5, in line with the need to update the Android API level to 33.

Migration instructions can be found here: Updating from Capacitor 4 to Capacitor 5

Included in the instructions is the upload of Android Studio.

0

Two questions (could probably have been submited separetly)

  1. compileSdkVersion vs targetSdkVersion: You can only update the targetSdkVersion. The compileSdkVersion upgrade will provide new APIs and maybe remove some, that's why you have a compilation error (and probably not when updating the target only)

See this question

  1. error: cannot find symbol settings.setAppCacheEnabled(true)

The setAppCacheEnabled has been deprecated and removed in new android versions. According to the doc on setCacheMode and LOAD_DEFAULT, the line is redundant if you want to enable the cache (default behavior: LOAD_DEFAULT), so you may be able to delete it?

Hugo Gresse
  • 17,195
  • 9
  • 77
  • 119
  • so if I remove that line then it will work as it is? Or removal of that line can impact or create some issue in code or app? @Hugo Gresse – Vaibhav Shah Jul 20 '23 at 06:03
  • you'll need to double-check, but according to my understanding of the documentation, the line seems unnecessary. Regarding the upgrade of Capacitor, it is generally a good practice to upgrade the base framework (Capacitor, React Native, etc) to upgrade the compileSdkVersion. Changing the targetSdkVersion has much lower impact though – Hugo Gresse Jul 20 '23 at 09:06