Capacitor: [Android] Kotlin for app & plugin & capacitor codebase?

Created on 15 Feb 2019  路  7Comments  路  Source: ionic-team/capacitor

Hi guys,

I've been browsing the capacitor source code and was wondering if you are open to modernizing & cleaning up the android codebase and plugin/app templates that are generated by npx @capacitor/cli plugin:generate, npx @capacitor/cli create and npx cap init.
I'm thinking: more recent Android gradle plugin, less unused boiler plate (that android studio project templates create, e.g. local jar dependencies, test dependencies on unused libraries, unused proguard files etc.), kotlin & androidx setup by default, app/plugin code generated in Kotlin.

If you are open to this I could contribute a pull request with what i have in mind and we can continue discussion based on that. If not - no hard feelings 馃槈

Cheers
Nemo

Most helpful comment

I agree that this is a major change and therefore too late for Capacitor 3 (but I hope that Capacitor 4 is doable).

Kotlin interops well with Java, but the native Android community is moving towards "Kotlin first".
To keep up with the Android world, the question is not if, but when the move should be made.
It already starts with the template app: If the template app is written in Kotlin, then it is faster to get up to speed with a decent Android setup.

Moreover, if done right, Kotlin could improve the quality of the Android code (for example, preventing random NullpointerExceptions like https://github.com/ionic-team/capacitor/pull/3553).

All 7 comments

Sure, we are open, but please, if you do it don鈥檛 do it all at once, better send small PRs that can be easily reviewed and tested as I don鈥檛 have experience with Kotlin

@jcesarmobile You can request help from other mamber that have more experience working with Kotlin

Yes I would definitely split up the work, we may need to discuss the changes based on small scope PRs. Will give it a shot next week 馃憤

Closing as it was more a question about if we were open to the changes, and not a real issue.

Are you still planning to convert Capacitor-Android to Kotlin, or open to accept PRs?

This would be especially important for the embedded use case; because Kotlin is now the primary language for native Android apps.

My understanding is by using Kotlin in Capacitor Android, we'd be adding the Kotlin dependency to every app. I don't see this as something we want to attempt to figure out for Capacitor 3, but perhaps a later major version.

Can you elaborate on why it's important for embedded? Kotlin should interop with Java quite well.

I agree that this is a major change and therefore too late for Capacitor 3 (but I hope that Capacitor 4 is doable).

Kotlin interops well with Java, but the native Android community is moving towards "Kotlin first".
To keep up with the Android world, the question is not if, but when the move should be made.
It already starts with the template app: If the template app is written in Kotlin, then it is faster to get up to speed with a decent Android setup.

Moreover, if done right, Kotlin could improve the quality of the Android code (for example, preventing random NullpointerExceptions like https://github.com/ionic-team/capacitor/pull/3553).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

natevw picture natevw  路  3Comments

peterpeterparker picture peterpeterparker  路  3Comments

nicobytes picture nicobytes  路  3Comments

gnesher picture gnesher  路  3Comments

TayKara picture TayKara  路  3Comments