apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

removed platform, added platform, and now build tools switched from 30.0.2 to 30.0.3 #1667

Closed caleb87 closed 7 months ago

caleb87 commented 7 months ago

I removed the platform and added it again, and now build tools wants 30.0.3 but it was using 30.0.2 previously.

Android Studio does not have 30.0.3 as an option to download.

I tried modifying cdv-gradle-config.json to use 30.0.2 but cordova just keeps changing it back.

How can I force cordova to use 30.0.2?

breautek commented 7 months ago

cordova-android@10 always used 30.0.3. If it was using 30.0.2 previously, it would have been something in your project overriding the android-buildToolsVersion config preference, or the BUILD_TOOLS_VERSION key (or a monkey patch in the gradle configs itself).

These options are mainly for development purposes. Changing them has a high risk of breaking the Cordova framework build as a lot of these options are tightly coupled with other framework dependencies. So I'd recommend keeping them as the defaults, unless if you really know what you're doing.

Android Studio does not have 30.0.3 as an option to download.

It does have 30.0.3 option, but you have to check Show Package Details to see alternate versions, instead of just the latest version available.

Screenshot from 2023-09-15 23-19-18

If the sdkmanager from the cmdline-tools package is on your PATH, android gradle will generally download and install the proper build tools as configured by Cordova automatically for you. Otherwise you can install it manually via the SDKManager.

Note that cordova-android@10 is out of support since it doesn't support API level required by Google Play. cordova-android@12 is the minimum version required for API 33 support, which is the required target level that Google Play enforces. See the Cordova Android Platform docs for what is required for cordova-android@12.

Closing as not a bug.

caleb87 commented 7 months ago

I realize now that I was looking for 33.0.3 but it said 30.0.3. It's been a long day of hair pulling.

I used cordova platform add android without @12 and it added an older version thus the 30.0.3 requirement.

I don't know why it doesn't default to v12 since it's on NPM.

I appreciate your help, and I regret wasting your time. I suppose if it had defaulted to v12 neither of our time would've been wasted!

erisu commented 7 months ago

You might be using and older version of the CLI.

Cordova use to pin the platforms' version to CLI and would always fetch the pinned version if you didn't specify.

In the current CLI it no longer pins the platforms' versions. It should now always fetch the latest version.

You might want to make sure your using the latest CLI as well.

breautek commented 7 months ago

I appreciate your help, and I regret wasting your time. I suppose if it had defaulted to v12 neither of our time would've been wasted!

No worries, happens to the best of us.

Older Cordova CLI tooling will pin to a major default that was available at the time of the release. I think this was done mostly for legacy reasons that didn't really make much sense with modern tooling. Current Cordova CLI, like Erisu said no longer does pins and will use the latest version available by default.

You can upgrade using npm install -g cordova@latest, or npm install cordova@latest if you're using local project installs. I'd advise to also upgrade NodeJS to at least the current LTS version as well.