Skip to content

fix: make 'android-lang' optional, with java as default#149

Merged
OS-pedrogustavobilro merged 10 commits intomainfrom
fix/android-lang-optional
Mar 23, 2026
Merged

fix: make 'android-lang' optional, with java as default#149
OS-pedrogustavobilro merged 10 commits intomainfrom
fix/android-lang-optional

Conversation

@OS-pedrogustavobilro
Copy link
Copy Markdown
Contributor

Description

This PR updates the recently added 'android-lang' to be optional, and never be prompted. The default (if no 'android-lang' is provided) was made to be Java. If users want kotlin, they'll have to explicitly set the argument when running the command.

This could be considered a breaking change, but since we're in 0.x version numbers, we're more lenient with breaking changes.

Also fixed a minor bug where when using 'kt' for 'android-lang', the java source directory was not getting removed.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation

Rationale / Problems Fixed

We had released a version where Android Language was always prompted, and the option selected by default was kotlin. Some time after the team had some internal discussions, and decided that we should stick to Java, since it is the Android Language that Capacitor framework is built on, and we may switch the default to Kotlin in the future whenever we migrate Capacitor to use Kotlin.

Having a default made it less relevant for the Android Language option to be prompted, so we removed it in order to have one less prompt option for the command. The plan will be as well to update the capacitor-docs to better let users know of this option, improving discoverability.

Tests or Reproductions

If you want, you may pull the branch, build it, and run it with different 'android-lang' values (and also with no value), and see that you are never prompted for the Android Language

Platforms Affected

  • Android
  • iOS
  • Web

@OS-pedrogustavobilro OS-pedrogustavobilro requested a review from a team March 23, 2026 09:55
@OS-pedrogustavobilro OS-pedrogustavobilro self-assigned this Mar 23, 2026
Copy link
Copy Markdown
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if kt is also a valid value, should be documented, or if not, it should not accept kt

@OS-pedrogustavobilro
Copy link
Copy Markdown
Contributor Author

Hmm, currently in 0.21.0 kt is valid as a shorthand for kotlin, but it wasn't documented. Then during this PR I saw there was an issue and had to add additional logic for it. Butkt doesn't add much, it was just not to type 4 extra characters 😅

So now I feel more inclined to drop it, but it is a breaking change technically, but since we're on 0.x versions, it's more acceptable.

Are you ok with removing kt with that said @jcesarmobile ?

@jcesarmobile
Copy link
Copy Markdown
Member

Whatever you prefer.

Breaking changes are not a big concern for this package since it's a tool and also it's on 0.x as you said.
Adding kotlin support was also a breaking change since it required an extra param.

@OS-pedrogustavobilro
Copy link
Copy Markdown
Contributor Author

Ended up removing the 'kt' option.

Comment thread src/options.ts Outdated
debug(`invalid option: --%s %O: %s`, option, value, validatorResult);

// 'android-lang' is not prompted, so it should fail if invalid
if (option === 'android-lang' && value !== undefined && value !== '') {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (option === 'android-lang' && value !== undefined && value !== '') {
if (option === 'android-lang') {

at this point it can't be undefined or empty, so no need to check

Comment thread src/options.ts Outdated
license: string;
description: string;
'android-lang': string;
'android-lang'?: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not really optional since if not defined it will be set to java.

If you not make it optional here, you can avoid setting java as default in several places in src/template.ts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah true, I was tinkering with it in an earlier version of the PR, but yeah this shouldn't be optional.

Well spotted!

@OS-pedrogustavobilro OS-pedrogustavobilro merged commit c2274d0 into main Mar 23, 2026
4 checks passed
@OS-pedrogustavobilro OS-pedrogustavobilro deleted the fix/android-lang-optional branch March 23, 2026 18:23
@markemer markemer restored the fix/android-lang-optional branch March 23, 2026 18:23
markemer added a commit that referenced this pull request Mar 23, 2026
markemer added a commit that referenced this pull request Mar 23, 2026
@markemer markemer deleted the fix/android-lang-optional branch March 23, 2026 18:28
jcesarmobile added a commit that referenced this pull request Mar 24, 2026
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

Successfully merging this pull request may close these issues.

3 participants