What is possible knowing little.. app development

Occasionally there is surprise to discover what is possible and what is practical.

Turns out building phone apps, is not much more complex than a 1000 piece jigsaw… though likely more complex for depth, getting something done from nothing, is possible.

Add ideas to time and a computer with >10GB memory…

… below on the back of a few weeks learning is an abc for those who want to try!
… and not just for mobile but all platforms…

Having dropped my unbreakable phone, looking at the new one and wondering what was possible, I discovered Flutter.

Flutter is a tagging of intent like html and with a Flutter-Rust bridge, becomes quite powerful for what is tempts might be possible going forward.

Flutter too is a lot easier to work with than Rust; the Android Studio is simple to use and a step up from the Visual Studio Code that supports Rust - error correcting on the fly.

I’m not the expert there are other options and I was looking last year over Tauri+React but that became harder to work with getting stuck with dependencies for React:Native.

So, fyi Flutter is atm 41% of apps cf React seemingly 38%. Flutter is also the basis of Fuchsia which is the operating system that is expected to replace Android… and with the promise of build once working on all platforms… seems worth exploring. There is still work to tweak the differences between platforms and the build has to be on the OS relative to the platform - so, Linux/Android; MacOS/iOS; Windows and limited by time/money my offering is simply atm for Linux/Andriod and Android does not have CLI; so, the apk I’ve spawned is just for the curiousity of what is possible but nice to see… and I might post some more of that once I’m done tweaking it.

To encourage those who think they cannot, then I will suggest if I can; likely you can…
though it seems the compile and emulator tips >9GB memory at times;

So, if 16GB memory, then app develop!.. where ! is not null… option on padding out proof of concepts, as I’m looking to do… or something else rather than nothing, seems like a good idea.

Learning how to setup the environment, was the harder part of this; so, I’ll put here the abc here for anyone who wants to try… any diff apologies; there are some links there for more detail, if you run aground of those steps.

Like all magic, it breaks down into moving a series of little steps forward…
:magic_wand:

Expand here for the abc to developing an app with the Flutter-Rust bridge

Glossary: 
	ADK		Android Development Kit
	SDK		Software Development Kit
	NDK		Native Development Kit
	ABI		Application binary interface

## Linux abc

## Create a core locations for tools:
# eg /mnt/vault/dev-tools/
# expecting that will hold folders as:
/mnt/vault/dev-tools/Android/android-studio
/mnt/vault/dev-tools/Android/Sdk
/mnt/vault/dev-tools/flutter

========= Rust
#for cargo;rustc; ++
#from https://www.rust-lang.org/tools/install
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

#append to .bashrc
source "$HOME/.cargo/env"

rustc --version
# eg rustc 1.65.0 (897e37553 2022-11-02)

## Optional: install of VS Code, useful for hacking at rust and other code
https://code.visualstudio.com/docs/setup/linux
search in code then to add extension: rust-analyzer

=========/Rust

========= Android Studio ====================
https://developer.android.com/studio
extract in /mnt/vault/dev-tools/Android
to see /mnt/vault/dev-tools/Android/android-studio

https://next--tauri.netlify.app/next/guides/getting-started/prerequisites/linux/

# add to .bashrc
export JAVA_HOME=/mnt/vault/dev-tools/Android/android-studio/jbr
Edit: updates are many and hard to track.. seems to have reverted to /jre

### Get add-ons from SDK manager
# Platforms
    Android SDK Platform 33
# Tools (lastest versions)
    Android SDK Build-Tools
    NDK (Side by side)
    Android SDK Command-line Tools
    CMake
	Android Emulator
	Android SDK Platform Tools
## to avoid confusion
# Noting [LLDB] is now part of "NDK (Side by Side)" and "CMake" components
# Noting [Google USB Driver] seems not an option or required now.

# Make the NDK visible for running Flutter
echo "ANDROID_NDK=/mnt/vault/dev-tools/Android/Sdk/ndk/25.1.8937393" >> ~/.gradle/gradle.properties

# https://developer.android.com/studio/projects/install-ndk
# pre accept licences in terminal with:
yes | /mnt/vault/dev-tools/Android/Sdk/cmdline-tools/latest/bin/sdkmanager --licenses

=========/Android Studio ====================

========= Flutter ====================
https://docs.flutter.dev/get-started/install/linux 
flutter doctor
flutter doctor --android-licenses
dart --disable-analytics
flutter config --no-analytics

Install plugins [Dart; Flutter; Gradianto]
Edit: [Zero width character locator] is optional but does magic removing invisible whitespace that creeps in. Useful especially for translation copy.

=========/Flutter ====================

========= NDK for building Rust on different platforms ====================
https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html
https://apilevels.com/

#Building for core Android archetectures:
	= ABI =			= Triple =
	armeabi-v7a 	armv7a-linux-androideabi
	arm64-v8a 		aarch64-linux-android
	x86 			i686-linux-android
	x86-64 			x86_64-linux-android

# Many others exist: $ rustup target list
the Android instances then:
	aarch64-linux-android
	arm-linux-androideabi
	i686-linux-android
	x86_64-linux-android
	armv7-linux-androideabi			#NDK option to build is not obvious
	thumbv7neon-linux-androideabi	#NDK option to build is not obvious


### build NDKs
cd /mnt/vault/dev-tools/NDKs
export ANDROID_HOME="/mnt/vault/dev-tools/Android/Sdk"
export NDK_HOME="$ANDROID_HOME/ndk/25.1.8937393"

/mnt/vault/dev-tools/Android/Sdk/ndk/25.1.8937393/build/tools/make_standalone_toolchain.py --api 31 --arch arm --install-dir NDK/arm
/mnt/vault/dev-tools/Android/Sdk/ndk/25.1.8937393/build/tools/make_standalone_toolchain.py --api 31 --arch arm64 --install-dir NDK/arm64
/mnt/vault/dev-tools/Android/Sdk/ndk/25.1.8937393/build/tools/make_standalone_toolchain.py --api 31 --arch x86 --install-dir NDK/x86
/mnt/vault/dev-tools/Android/Sdk/ndk/25.1.8937393/build/tools/make_standalone_toolchain.py --api 31 --arch x86_64 --install-dir NDK/x86_64
###/build NDKs

### rustup architecture
rustup target arm-linux-androideabi aarch64-linux-android i686-linux-android add x86_64-linux-android
# not useful without NDK: rustup target add armv7-linux-androideabi thumbv7neon-linux-androideabi

# simpler instance for another non-Android version #unclear the use for this might be raspberry pi ??
rustup target add arm-unknown-linux-gnueabihf
# not useful without NDK: rustup target add armv7-unknown-linux-gnueabihf

###/rustup architecture

### cargo build

# this saves a lot of time and complexity:
https://github.com/bbqsrc/cargo-ndk
cargo install cargo-ndk

# noting later will do this in the ./native directory
# cargo ndk -t armeabi-v7a -t arm64-v8a -t x86 -t x86_64 -o ./jniLibs build --release 

=========/NDK for building Rust on different platforms ====================

========= Flutter to Rust bridge ====================

https://blog.logrocket.com/using-flutter-rust-bridge-cross-platform-development/
https://blog.logrocket.com/using-flutter-rust-bridge-cross-platform-development/#creating-flutter-rust-bridge-project

https://cjycode.com/flutter_rust_bridge
https://cjycode.com/flutter_rust_bridge/integrate.html
-------------
# A useful boilerplate to work from, allowing flutter and rust to work together and become compiled in Android Studio for many platforms

git clone https://github.com/Desdaemon/flutter_rust_bridge_template

=========/Flutter to Rust bridge ====================

========= Flutter + Android Studio ====================
## Example template of Flutter + Rust in Android Studio
# in Android Studio, start and emulator target and run flutter in the terminal, will use that emulating instance
flutter run

=========/Flutter + Android Studio ====================

========= Linux appimage from Bundle ====================

# Flutter oddly created a folder Bundle rather than just one executable
# So, appimage is done simply following abc here:
https://odilondamasceno.medium.com/creating-appimage-with-flutter-d19ef8b53158
# there seem to be other ways suggested that look oddly complex but that one just works.

========= /Linux appimage from Bundle ====================

========= Trivia noted  ====================
Flutter cannot yet build apps for tvOS, watchOS, CarPlay, or Android Auto.
There is some limited support for Wear OS (formerly Android Wear).
Flutter has to add Bitcode support to deploy to tvOS and watchOS.
========= /Trivia noted  ====================

Hopefully that all makes sense.. written as a tracker for what I was learning at the time.
3 Likes