Running webassembly from Android Studio

I’m trying to run the inference from an Android studio native app. I tried from the C++ library but I couldn’t compile it.
Nowadays I’m trying to call the inference from the webassembly code, but I haven’t achieve it yet.
Has anybody tried that before?
Project ID:

Context/Use case:

Hello @djsilverav

I am not very familiar with Android development, I saw that you created a thread for the cpp integration here: Import C++ Impulse Library in Android Studio - #6 by djsilverav

I will let the community reply here as it is not something we officially support as of today.



Thanks a lot Louis for your reply. I decide to create a new thread based on the supposition that maybe there is a person who has worked on it.
If not, at least I tried. :sweat_smile:

1 Like

@djsilverav I tried the C++ library in Flutter and failed. I think the solution is to load the Model file found on your projects EI Dashboard and go from there.

After Many days, I think a got something @MMarcial and @louis. I’m running it from Android Studio. If you can replicate it, would be wonderful.

My solution:

  1. Download the webAssembly compressed file.
  2. In android studio I built a WebView object and load in-app content.
  3. Then, I copy the entire uncompressed files into the assets folder that you created in the previous step.
  4. If everything goes right, then you can load your own model like if It was running into a webpage and if you test it, you should be able to get a result.
    Here is where I started with the problems.
  5. Share data between Javascript Code and Java or Kotlin code. For that part I followed this tutorial Tutorial 1 and [Android Studio WebView Documentation].(WebView  |  Android Developers)
    Basically here what I did was to save into a float array all the data that you need to run the impulse.
    Then, I converted to a string for sharing between Java and Javascript interfaces.
    Finally, I converted that string that comes from Java into a float array Javascript object (like in the original WebAssembly file: index.html code).
  6. I send that object as an input of the impulse and It started to work.

I know that it is a few confusing but I’m still testing that everything goes right and I expect to record a small tutorial. I know that I’m not so good working with Android Studio and maybe I have many mistakes and there’s a faster way to run the impulse, but at least It was the only way to run the impulse directly from the mobile.

If you have questions, post it here and I will try to answer them as soon as possible. :smiley:

@djsilverav Congratulation! You are make headway!!

I got stuck at step 1. Where do I download the webAssembly compressed file?

Can you post your Android project code to GitHub?

Deployment/WebAssembly Package

I cannot post the full project because it is not just my project, but I can upload the test app where I load and made my experiments. It’s a bit disorganized, but I expect it could help you.

Just pay attention to mainActivity class | assets folder. and readme file :smiley: