News for hackers. Stuff that matters.
Re:Rust in the Android Platform by berkes on Tuesday April 06, 2021 @03:54PM (#26716607)
While it feels terribly hacky, one could probably write an Android-wrapper around Rust in Java. A rather big undertaking, I'd guess, since it means exposing all APIs to rust somehow.

An other approach would be to employ one of many thin webview wrappers, in which your app is HTML+Js+CSS. When such a webview wrapper supports WASM, the JS part could be written in rust.

Not something I'd do other than "to prove it can be done".

Re:Rust in the Android Platform by raphlinus on Tuesday April 06, 2021 @04:16PM (#26716839)
The "cargo apk" tool already exists to bundle Rust code into a NativeActivity that can be run without needing to write any additional Java code. The API surface so provided is more limited than the full toolkit, but could be useful in many domains. It's currently mostly used for games. I am using it for the Android port of piet-gpu, and it's working pretty well.
Re:Rust in the Android Platform by Argorak on Tuesday April 06, 2021 @04:07PM (#26716741)
The biggest problem here is that in Android, Java "owns" the app, so you will have to invert a lot of lines to make "develop a whole app in Rust" feel awesome.

But, TBH, I think Kotlin and Java are _indeed_ fine application languages.

What Rust is already quite often used for is for libraries that work on both iOS and Android. For a public example, see the Glean SDK: https://mozilla.github.io/glean/book/index.html

Re:Rust in the Android Platform by berkes on Wednesday April 07, 2021 @04:44AM (#26721982)
> But, TBH, I think Kotlin and Java

I agree wholeheartedly.

But there will be a demographic of people who know Rust and not Java, but who might want to build an app. Somewhat similar to how there is an apparent need for "HTML+JS+CSS"-devs to build native apps.

Re:Rust in the Android Platform by Argorak on Wednesday April 07, 2021 @05:46AM (#26722495)
Well, this is always a tradeoff: the cost of being away from the mainstream may outweigh familiarity with a programming language at some point.

I'm not sure if the argument for "HTML+JS+CSS" is purely familiarity, there's also technical arguments like portability and future-compatibility. But I _do_ hope that the portability story will become better in the coming years beyond just this stack.