mun icon indicating copy to clipboard operation
mun copied to clipboard

Android support

Open Wodann opened this issue 5 years ago • 5 comments

Mobile developers being one of our target audiences, we set the goal:

Leverage Mun's cross compilation to unlock hot reloading for console and mobile development.

Currently, Android is not one of Mun's supported target platforms.

The first steps towards achieving this goal, would be:

  • [ ] Investigate compilation of and linking to mun_runtime for Android-supported targets
  • [ ] Investigate opening of shared libraries (needed for *.munlibs) with the Android SDK

Wodann avatar Jun 10 '20 15:06 Wodann

Investigate compilation of and linking to mun_runtime for Android-supported targets

mun_runtime 0.3.0 and 0.2.0 compiles without a problem to armv7-linux-androideabi platform using cargo-apk.

Investigate opening of shared libraries (needed for *.munlibs) with the Android SDK

In case when one wants to release game that use mun as embedded language, he needs to inject all .munlib files into apk, for distribution purpose. So i tried that: saved .munlib in assets and then load it from AssetManager, problem is that asset manager open assets in the streaming mode(and that's the only way asset manager can), while mun_runtime uses libloading lib which accept only string path to file. So there need to be some specific code for android platform in that case.

~~I did not tried cases where .munlib loads from internal/external android storages.~~

legendiguess avatar Aug 25 '21 02:08 legendiguess

I tried case where mun_runtime read .munlib from external storage: Seems like it's reading .munlib without problems, but after that mun_runtime try to create temp file in "/data/local/tmp/.*", problem is that "/data/local/" path is protected on android system and it can't be used in android apps (maybe it can be on rooted devices).

Here example error output:

08-25 10:32:09.831 19215 19276 I RustStdoutStderr: thread '<unnamed>' panicked at 'Failed to spawn Runtime: Permission denied (os error 13) at path "/data/local/tmp/.tmpqOPqYS"', src\lib.rs:9:87

And so path for temp files should be changed in order to support android (tempfile crate is responsible for temp files and, i guess, also for "/data/local/" path).

legendiguess avatar Aug 25 '21 05:08 legendiguess

@legendiguess thanks for figuring all this out!

Could you raise an issue with tempfile regarding the incorrect location?

The compiler also has to get a new target so we can compile mun to arm.

baszalmstra avatar Aug 25 '21 20:08 baszalmstra

The compiler also has to get a new target so we can compile mun to arm.

Can you please explain? Doesn't rustc compiler already have all needed targets for android? (armv7-linux-androideabi, aarch64-linux-android, i686-linux-android, x86_64-linux-android)

legendiguess avatar Aug 26 '21 05:08 legendiguess

The rust compiler does, but the mun compiler also needs to be able to generate arm code. It doesnt yet.

baszalmstra avatar Aug 26 '21 08:08 baszalmstra