Is it possible to create Android apps using Rust?

Is it possible to create Android apps using Rust? If so is there some high level library out there to allow me to create apps using Rust?

Would it use Android's mobile app studio tool or would it be all text coding based with no GUI creation tool?

4 Likes

As far as I know vaguely, there's no GUI creation tool, or none that's ready for use. There's probably some way to use OpenGL to do it but it'd probably be easier to make a Game using that instead of a regular app.

1 Like

I am after creating a regular app.

Oh ok that is ok, but is there some high level library out there I can use?

1 Like

Yeah, after a little bit of looking it seems that there isn't really anything good for getting mobile GUIs on Android with Rust right now.

I'm not sure if it would be possible to use the android app studio tool to create the GUI and then use the ndk crate to write app logic, but it looks like there's no easy solution that's ready today.

3 Likes

I am using rust for a networking module, and then using FFI to communicate to/from the java/android GUI. Setting it up was non-trivial. I recommend getting the NDK!

2 Likes

Can this crate by any chance support creating GUI apps?

1 Like

NDK allows you to compile a .so (static library) from rust code that way you can statically call System.loadLibrary("mylib") from java.

Here is how to use FFI: (to communicate between rust/java) https://github.com/drrb/java-rust-example

If you're using android studio (DO IT!), follow this guide: https://github.com/mozilla/rust-android-gradle

Here's my rust/java app in android (see the tag at the bottom; it calls a rust function):

119036503_398271467806824_4186028347505401765_n

6 Likes

Looks interesting your app :slight_smile:

I see, thanks man.

Just a question out of curiosity, is it harder to use Java (with Android Studio) when programming an app vs using Rust (with Android Studio)?

I use Clion for Rust as my IDE, and use android studio for Java/Android. Rust is more difficult than Java (by an order of magnitude when first learning). I'm not sure if I answered your question?

What about when you are just using Rust for app development when you have understood how to use it? Is it harder than Java still?

Not really. Neither one is "harder" than the other once one feels comfortable in both. I prefer coding in rust overall, knowing that I can control precisely what my memory + lifetime guarantees are

2 Likes

Just to be clear, it seems like you think you can code rust in android studio. Is that what you think?

It's much harder to learn, and even when you're experienced in rust you'll probably need more time to do the same thing in rust compared to java. However, that'll be offset by the time you save on debugging because rust is naturally just better at that by a huge margin.

An off topic suggestion, try to put some thought into learning Kotlin for android since that is relatively less prone to errors. You may also consider doing android with Flutter, Flutter's dart is a fairly java like language so shouldn't be hard to pick up. And they all support using rust libraries in the back.

2 Likes

Aside: see Are We GUI Yet for the state of GUI libraries across Rust. Although there's nothing Android-specific (that I can see), it might be possible to, say, interface with electron and target Android.

You have to link it with Java.

I see.

Is this using Android app studio?

Hopefully one day.

Android studio? yes. Flutter is supported in Android studio. It also has great support on VSCode. Flutter is cross platform and works on IOS, Android, Desktop, Web.... tho only Ios and Android are considered stable.

I see

Are there additional reasons as to using Flutter over Java for developing Android apps other than cross platform support?

Am I able to also use Flutter without Android studio and use high level libraries to make GUI apps? Kinda like using HTML/CSS in that high level manner.

I personally like the way Flutter does GUI over how it's done in native Android. You can check out Jetpack Compose with Kotlin, which works in a similar way... but it's not production ready yet. I'm not sure what exactly you mean by high level but Flutterr is a Ui Framework and it's pretty easy to make good looking animated UI with it. It has a decent ecosystem and yes you can use it outside android studio.

We shouldn't really continue this conversation here, since this has nothing to do with rust :sweat_smile:

Wait, when you say this you mean that Flutter is not a programming language, it is a GUI software/app creation tool, just like with Android Studio?

Oh yeah but could I please just ask anways so I know what tool is really right for me please?

It's a framework. Do you know of Vue/React? they aren't a software like android studio, they aren't a programming language either since they're javascript, but they're setup in a way that makes it easy to design ui with it.
Flutter is a framework too, it's not a programming language. Flutter's language is dart. I think you'll understand what it is if you watch a video on how to setup flutter with VSCode and make a basic app on youtube.

2 Likes