Skip to content

What do you need

Maciej Gorywoda edited this page Jan 21, 2021 · 5 revisions
  1. You need a good computer. Haha, but for real. I have Lenovo Ideapad Y700 - Intel Core i7, 8GB RAM, and an SSD hard drive, and the compilation of that dummy app took me over two minutes and ate all the RAM.

  2. You need Linux. It looks like at least for now only the Linux version of GraalVM can build Android apps. And that's what we will be using.

  3. Download GraalVM for Linux, for Java 11 from here: https://github.com/graalvm/graalvm-ce-builds/releases.

  4. Add this to your ~/.bash_profile:

    export GRAALVM_HOME=<path to GraalVM home directory>
    export JAVA_HOME=$GRAALVM_HOME
    export PATH=$GRAALVM_HOME/bin:$PATH
    
  5. When you type in java -version it should display something like this now:

    > java -version
    openjdk version "11.0.10" 2021-01-19
    OpenJDK Runtime Environment GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06)
    OpenJDK 64-Bit Server VM GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)
    
    

(The GraalVM version may differ).

  1. I'm not entirely sure if this is needed for what we're going to do or will the compilation do it for us, but in case it doesn't, manually download GraalVM's native-image:

    gu install native-image
    

    gu should be available now in your console because of $GRAALVM_HOME/bin in your PATH. Also, read this and install whatever you need: https://www.graalvm.org/reference-manual/native-image/#prerequisites

  2. You will need adb , "Android Debug Bridge", to connect to your Android device and install the app on it: https://www.fosslinux.com/25170/how-to-install-and-setup-adb-tools-on-linux.htm . Oh, and if it's not clear yet, you will need an Android device ;)

  3. Make sure your gcc is at least version 6. It turned out my Linux distro had gcc 5.4 - a bit of a surprise since I experimented with C recently and was pretty sure I have all the modern stuff. But then I remembered I use clang, not gcc. You can try follow these steps: https://tuxamito.com/wiki/index.php/Installing_newer_GCC_versions_in_Ubuntu . On top of that, you will need some specific C libraries (like GTK) to build the native image and it varies from one computer to another, so I can't tell you exactly what to do. But it shouldn't be a big problem. Just follow error messages saying that you lack something and google how to install them. In my case this was the list:

  libasound2-dev (for pkgConfig alsa)
  libavcodec-dev (for pkgConfig libavcodec)
  libavformat-dev (for pkgConfig libavformat)
  libavutil-dev (for pkgConfig libavutil)
  libfreetype6-dev (for pkgConfig freetype2)
  libgl-dev (for pkgConfig gl)
  libglib2.0-dev (for pkgConfig gmodule-no-export-2.0)
  libglib2.0-dev (for pkgConfig gthread-2.0)
  libgtk-3-dev (for pkgConfig gtk+-x11-3.0)
  libpango1.0-dev (for pkgConfig pangoft2)
  libx11-dev (for pkgConfig x11)
  libxtst-dev (for pkgConfig xtst)

On the other hand, it looks like you don't need to install Android SDK manually. GraalVM will do it for you. (But you can use your own installation if you want to).