rust-mobile / ndk

Rust bindings to the Android NDK
Apache License 2.0
1.14k stars 112 forks source link

Questions regarding this crate #123

Closed Joe23232 closed 2 years ago

Joe23232 commented 3 years ago

Hi I have some questions regarding this crate:

  1. Am I able to make full blown Android applications by using this crate and the orbtk GUI library crate?
  2. Is it stable or beta/alpha?
  3. Is there a docs page that is similar to the Rust Programming Book?
  4. Is it more difficult to use or easier to use compared to using Android Studio Java?
dvc94ch commented 3 years ago
  1. Ask them 2. It works reliably 3. No 4. Why don't you try both and tell me?
Joe23232 commented 3 years ago
  1. Do I have full API access just like with Android Studio Java app development (minus the GUI support)?
dvc94ch commented 3 years ago

You have access to the ndk api, for many things you'll need a good jni library. But my guess would be that if you need to ask these questions, you'll be more happy with Android studio.

dvc94ch commented 3 years ago

I mean you could try https://github.com/hecrj/iced, I think it has android support. Unless you want to do opengl/Vulkan rendering yourself that might be your best bet. And if you're interested in how android works, reading the code in this repo might be interesting to you.

Joe23232 commented 3 years ago

Interesting, thanks for the link mate :)

Joe23232 commented 3 years ago

@dvc94ch Hey mate, unfortunately iced does not support Android according to another person I am chatting with :( Just letting you know, do you happen to know other library crates that are easy to use and it supports Android and possibly Windows?

dvc94ch commented 3 years ago

Well, I didn't say it would necessarily be easy and I am busy with other stuff, so I really don't have the time to try it out. If you want a ready made solution there is Android studio, which was my first recommendation.

dvc94ch commented 3 years ago

Any idea how long it will take you to build your app? If it takes you one year the guy said it would work. If you're done after a month, at least you'll understand how iced works, which is 50% of the puzzle.

dvc94ch commented 3 years ago

Apparently I was wrong @cryptoquick built a moderately complex desktop app in rust. I guess that's why I remembered it, as I didn't think that was possible at the time.

cryptoquick commented 3 years ago

It's likely quite possible, plenty of tools are there, but the work has to be put in to try it and see what works and what doesn't.

See some iOS-related discussion here: https://github.com/hecrj/iced/issues/302#issuecomment-757070775

As for Android, only reason I think cargo mobile hasn't been tried in a similar way is, most people pick one or the other. Someone happened to make Iced work on iOS because they had an iOS device. Time to try with Android!

I'm not a mobile developer, primarily because the thought of publishing on an app store drives me crazy. However, the dream of wanting to build full desktop, web, and mobile compilation targets in a single project seems feasible enough with Rust, Iced, wgpu, and cargo mobile. It's also a worthwhile dream. How much works, and how well, is unclear, however. Will networking or storage APIs work? Who knows. There's definitely plenty to try, at least.

cryptoquick commented 3 years ago

Also, check this out: https://github.com/BrainiumLLC/cargo-mobile/pull/4

Joe23232 commented 3 years ago

As for Android, only reason I think cargo mobile hasn't been tried in a similar way is, most people pick one or the other. Someone happened to make Iced work on iOS because they had an iOS device. Time to try with Android!

Sorry just one question, what is the difference between cargo mobile and android-ndk-rs?

So I was looking at another project called fltk-rs and like this also supports Android, however the owner claims that it failed to work with android-ndk-rs and apparently he forgot the reason why, he claims it only works on Android Studio. This particular project seems simpler than Iced.

However, the dream of wanting to build full desktop, web, and mobile compilation targets in a single project seems feasible enough with Rust, Iced, wgpu, and cargo mobile.

So if I wanted to print "Hello World" to the screen then it would be the exact same code, right?

Also, check this out: BrainiumLLC/cargo-mobile#4

Interesting mate :)

cryptoquick commented 3 years ago

As for Android, only reason I think cargo mobile hasn't been tried in a similar way is, most people pick one or the other. Someone happened to make Iced work on iOS because they had an iOS device. Time to try with Android!

Sorry just one question, what is the difference between cargo mobile and android-ndk-rs?

I'm not familiar with Android development, but I'm wondering if they reimplemented some of what android-ndk-rs does in here: https://github.com/BrainiumLLC/cargo-mobile/blob/master/src/android/ndk.rs

However, the dream of wanting to build full desktop, web, and mobile compilation targets in a single project seems feasible enough with Rust, Iced, wgpu, and cargo mobile.

So if I wanted to print "Hello World" to the screen then it would be the exact same code, right?

The idea would be to write, say, an app that displays the text "Hello World" and to use rust cfg target attribute and/or feature macros to break up whatever needed to be different on each platform, but keep the majority of business and presentation logic the same.

Joe23232 commented 3 years ago

I'm not familiar with Android development, but I'm wondering if they reimplemented some of what android-ndk-rs does in here: https://github.com/BrainiumLLC/cargo-mobile/blob/master/src/android/ndk.rs

Interesting

The idea would be to write, say, an app that displays the text "Hello World" and to use rust cfg target attribute and/or feature macros to break up whatever needed to be different on each platform, but keep the majority of business and presentation logic the same.

That sounds pretty good, so I suppose tries to adhere to the philosophy "Write once, run everywhere"?

cryptoquick commented 3 years ago

That's the dream! Still early days in Rust. Who knows, maybe in a couple of years, Iced might be replacing Flutter and Ionic in people's apps, and Iced would be adding TUI, JSON-RPC, GraphQL, and headless testing targets. Sigh. A guy can dream. Everything's moving to Rust.

In a week or so, @dvc94ch , I'll be working on upgrading Fuzzr to the latest ipfs_embed. I want to get started on a Gemini renderer, which Iced could be decent at. With IPFS embedded in the browser, every browser would be a server... Just how it should've been in the first place.

Joe23232 commented 3 years ago

That's the dream! Still early days in Rust. Who knows, maybe in a couple of years, Iced might be replacing Flutter and Ionic in people's apps, and Iced would be adding TUI, JSON-RPC, GraphQL, and headless testing targets. Sigh. A guy can dream. Everything's moving to Rust.

I really hope that =D

In a week or so, @dvc94ch , I'll be working on upgrading Fuzzr to the latest ipfs_embed. I want to get started on a Gemini renderer, which Iced could be decent at. With IPFS embedded in the browser, every browser would be a server... Just how it should've been in the first place.

Sorry mate but what is Fuzzer?

dvc94ch commented 3 years ago

So I think the discussion might be going off topic.

The difference between cargo apk and cargo mobile is (apart from that they were developed at roughly the same time) is that cargo mobile requires Android studio and some Java boilerplate to work and here we don't need either, but I might be mistaken.

francesca64 commented 3 years ago

This discussion has definitely gone off topic, so please direct any further cargo-mobile questions/discussion to BrainiumLLC/cargo-mobile#23, and anything else that's not related to android-ndk-rs to anywhere else.

cargo mobile requires Android studio and some Java boilerplate to work

It actually doesn't have any Java boilerplate, though it does generate every other flavor of boilerplate under the sun, so you might as well be right. I also don't believe Android Studio is required, though gradle is.

The difference in a nutshell is that cargo-apk is a cool standalone tool for building your Rust project as an APK, whereas cargo-mobile is designed to integrate with Android Studio and Xcode. They both give you an APK in the end, but follow two different equally-valid approaches to getting there.

cryptoquick commented 3 years ago

That's a great explanation, thank you, @francesca64 !