GNU bug report logs - #65207
30.0; More instructions for how to build Android emacs, are needed

Previous Next

Package: emacs;

Reported by: Johan Widén <j.e.widen <at> gmail.com>

Date: Thu, 10 Aug 2023 13:22:02 UTC

Severity: wishlist

Found in version 30.0

Full log


View this message in rfc822 format

From: Johan Widén <j.e.widen <at> gmail.com>
To: 65207 <at> debbugs.gnu.org
Subject: bug#65207: 30.0; More instructions for how to build Android emacs, are needed
Date: Thu, 10 Aug 2023 11:23:41 +0200
[Message part 1 (text/plain, inline)]
Note: This is a request for an enhancement of the emacs version 30
documentation. I am writing this submission in emacs 29.1, so the
current environment details are irrelevant.

I needed to build and run the Android emacs APK, to try and track down a
bug. As I am a novice regarding building Android apps, finding out how
to do this required considerable effort. I therefore suggest that
information similar to what I include below, is added as an appendix to
java/INSTALL.

First I suggest that the emacs repo top level README or INSTALL should
include a reference to java/INSTALL. Perhaps something like this:
• For instructions on how to build Android emacs, see ./java/INSTALL.

Here is now my build and run instructions:

I am using Ubuntu, so these instructions are Ubuntu specific, but should
be easily adaptable to other linux based distributions. Note that
Android Studio, Android SDK, Android NDK can be downloaded from the
software provider, if they are not available in your linux distributions package manager.

I first installed Android Studio. It is available in the Ubuntu snap store:

• sudo snap install android-studio

I then ran Android Studio to set it up, and also tried to build a sample
project. I believe that at this point $HOME/Android with important
subdirectory $HOME/Android/Sdk/build-tools/33.0.1 was added to my $HOME
directory. See below why this was important.

I then installed a number of apt packages:
• sudo apt install android-sdk
• sudo apt install sdkmanager
• sudo apt-get install crossbuild-essential-arm64
• sudo apt install google-android-ndk-r25c-installer

Not sure if package crossbuild-essential-arm64 is needed.

The SDK was installed under /usr/lib/android-sdk.
The NDK was installed under /usr/lib/android-ndk.

The sdk supports creating Java based apps.
The ndk supports creating apps using C or C++ source.

Now something important: The sdk installation created, among other
things, a directory /usr/lib/android-sdk/build-tools/debian. I tried
building with that, but this did not work, as the contents of the
directory is very incomplete. That was when I discovered $HOME/Android, and
the important directory $HOME/Android/Sdk/build-tools/33.0.1. Using that
directory instead of the debian directory, I was able to make a
successful build.

I added a number of directories to my PATH, but I do not know if that is
necessary:
if [ -d “/usr/lib/android-sdk/tools/bin” ] ; then
    PATH=“/usr/lib/android-sdk/tools/bin:$PATH”
fi
if [ -d “/usr/lib/android-sdk/platform-tools” ] ; then
    PATH=“/usr/lib/android-sdk/platform-tools:$PATH”
fi
if [ -d “$HOME/Android/Sdk/build-tools/33.0.1” ] ; then
    PATH=“$HOME/Android/Sdk/build-tools/33.0.1:$PATH”
fi
if [ -d “/usr/lib/android-ndk” ] ; then
    PATH=“/usr/lib/android-ndk:$PATH”
fi

To install cross compilers for android I now did:
• sudo sdkmanager –list
• sudo sdkmanager “platforms;android-33”

Installed under “/opt/android-sdk//platforms/android-33”.
ANDROID_CC are under
/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin

I then ran the following in the top directory of the emacs repo:

./configure –with-android=/opt/android-sdk/platforms/android-33/android.jar \
ANDROID_CC=/usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang  \
SDK_BUILD_TOOLS=$HOME/Android/Sdk/build-tools/33.0.1

make all

To run the emulator I started Android Studio, and in the menu in the
upper right corner selected “Virtual Device Manager”. I could then
select and run the default emulator device
“Pixel_3A_API_34_extension_level_7_x86_64”. To load the APK into the
emulator I started a file manager and dragged and dropped the APK file
onto the emulator display. The computer keyboard can be used for typing into Android emacs.
[Message part 2 (text/html, inline)]

This bug report was last modified 1 year and 342 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.