Skip to content

Instantly share code, notes, and snippets.

@xavetar
Created May 10, 2022 04:32
Show Gist options
  • Select an option

  • Save xavetar/0ae34ee670cd75f1192188f57cd4c850 to your computer and use it in GitHub Desktop.

Select an option

Save xavetar/0ae34ee670cd75f1192188f57cd4c850 to your computer and use it in GitHub Desktop.
Build Android Emulator (aarch64/arm64 and etc.)
# Original from https://developer.android.com/studio/releases/emulator#emulator_for_arm64_hosts
mkdir emu
cd emu
repo init -u https://android.googlesource.com/platform/manifest -b emu-master-dev --depth=1
repo sync -qcj 24
cd external/qemu
pip install absl-py
pip install urlfetch
# sudo apt-get install crossbuild-essential-arm64
python3 android/build/python/cmake.py --noqtwebengine --noshowprefixforinfo --target linux_aarch64
@Marietto2008
Copy link

Marietto2008 commented Sep 10, 2024

On the Jetson Nano 4 GB with Ubuntu 22.04 installed it fails :

aresuser@jetson:~/Scrivania/Android$ mkdir emu

aresuser@jetson:~/Scrivania/Android$ cd emu

aresuser@jetson:~/Scrivania/Android/emu$ repo init -u https://android.googlesource.com/platform/manifest -b emu-master-dev --depth=1

Downloading Repo source from https://gerrit.googlesource.com/git-repo

Your identity is: Mario Zio <[email protected]>
If you want to change this, please re-run 'repo init' with --config-name
repo has been initialized in /home/aresuser/Scrivania/Android/emu

aresuser@jetson:~/Scrivania/Android/emu$ repo sync -qcj 4

^C================================================================================
Repo command failed: RepoUnhandledExceptionError
	
aresuser@jetson:~/Scrivania/Android/emu$ repo sync -j4

Fetching: 100% (64/64), done in 46m2.395s
Checking out: 100% (64/64), done in 45m56.440s
repo sync has finished successfully.

aresuser@jetson:~/Scrivania/Android/emu$ cd external/qemu

aresuser@jetson:~/Scrivania/Android/emu/external/qemu$ pip install absl-py

Defaulting to user installation because normal site-packages is not writeable
Collecting absl-py
  Downloading absl_py-2.1.0-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.7/133.7 kB 1.2 MB/s eta 0:00:00
Installing collected packages: absl-py
Successfully installed absl-py-2.1.0

[notice] A new release of pip is available: 23.1.2 -> 24.2
[notice] To update, run: python3.10 -m pip install --upgrade pip

aresuser@jetson:~/Scrivania/Android/emu/external/qemu$ python3.10 -m pip install --upgrade pip

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /home/aresuser/.local/lib/python3.10/site-packages (23.1.2)
Collecting pip
  Downloading pip-24.2-py3-none-any.whl (1.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 4.4 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 23.1.2
    Uninstalling pip-23.1.2:
      Successfully uninstalled pip-23.1.2
Successfully installed pip-24.2

aresuser@jetson:~/Scrivania/Android/emu/external/qemu$ pip install urlfetch

Defaulting to user installation because normal site-packages is not writeable
Collecting urlfetch
  Downloading urlfetch-2.0.1.tar.gz (67 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: urlfetch
  Building wheel for urlfetch (setup.py) ... done
  Created wheel for urlfetch: filename=urlfetch-2.0.1-py3-none-any.whl size=69880 sha256=7c1f14480115fd31a57ae6b6751a47436efd12fb385bc16268e3db205d532387
  Stored in directory: /home/aresuser/.cache/pip/wheels/f6/3a/69/9dc4789b65a0d9bbf1245f2406106732fac563620a6999a5bb
Successfully built urlfetch
WARNING: Error parsing dependencies of devscripts: Invalid version: '2.22.1ubuntu1'
Installing collected packages: urlfetch
Successfully installed urlfetch-2.0.1

aresuser@jetson:~/Scrivania/Android/emu/external/qemu$ sudo apt-get install crossbuild-essential-arm64

Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze... Fatto
Lettura informazioni sullo stato... Fatto   
I seguenti pacchetti NUOVI saranno installati:
  cross-config crossbuild-essential-arm64 dpkg-cross libconfig-auto-perl libconfig-inifiles-perl
  libdebian-dpkgcross-perl libxml-simple-perl libyaml-perl
0 aggiornati, 8 installati, 0 da rimuovere e 14 non aggiornati.
È necessario scaricare 239 kB di archivi.
Dopo quest'operazione, verranno occupati 777 kB di spazio su disco.
Continuare? [S/n] s
Scaricamento di:1 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 libconfig-inifiles-perl all 3.000003-1 [40,5 kB]
Scaricamento di:2 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 libxml-simple-perl all 2.25-1 [64,9 kB]
Scaricamento di:3 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 libyaml-perl all 1.30-1 [58,2 kB]
Scaricamento di:4 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 libconfig-auto-perl all 0.44-1.1 [16,7 kB]
Scaricamento di:5 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 libdebian-dpkgcross-perl all 2.6.18+nmu2 [15,6 kB]
Scaricamento di:6 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 cross-config all 2.6.18+nmu2 [16,8 kB]
Scaricamento di:7 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 dpkg-cross all 2.6.18+nmu2 [22,4 kB]
Scaricamento di:8 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 crossbuild-essential-arm64 all 12.9ubuntu3 [3.714 B]
Recuperati 239 kB in 1s (453 kB/s)                     
Selezionato il pacchetto libconfig-inifiles-perl non precedentemente selezionato.
(Lettura del database... 484593 file e directory attualmente installati.)
Preparativi per estrarre .../0-libconfig-inifiles-perl_3.000003-1_all.deb...
Estrazione di libconfig-inifiles-perl (3.000003-1)...
Selezionato il pacchetto libxml-simple-perl non precedentemente selezionato.
Preparativi per estrarre .../1-libxml-simple-perl_2.25-1_all.deb...
Estrazione di libxml-simple-perl (2.25-1)...
Selezionato il pacchetto libyaml-perl non precedentemente selezionato.
Preparativi per estrarre .../2-libyaml-perl_1.30-1_all.deb...
Estrazione di libyaml-perl (1.30-1)...
Selezionato il pacchetto libconfig-auto-perl non precedentemente selezionato.
Preparativi per estrarre .../3-libconfig-auto-perl_0.44-1.1_all.deb...
Estrazione di libconfig-auto-perl (0.44-1.1)...
Selezionato il pacchetto libdebian-dpkgcross-perl non precedentemente selezionato.
Preparativi per estrarre .../4-libdebian-dpkgcross-perl_2.6.18+nmu2_all.deb...
Estrazione di libdebian-dpkgcross-perl (2.6.18+nmu2)...
Selezionato il pacchetto cross-config non precedentemente selezionato.
Preparativi per estrarre .../5-cross-config_2.6.18+nmu2_all.deb...
Estrazione di cross-config (2.6.18+nmu2)...
Selezionato il pacchetto dpkg-cross non precedentemente selezionato.
Preparativi per estrarre .../6-dpkg-cross_2.6.18+nmu2_all.deb...
Estrazione di dpkg-cross (2.6.18+nmu2)...
Selezionato il pacchetto crossbuild-essential-arm64 non precedentemente selezionato.
Preparativi per estrarre .../7-crossbuild-essential-arm64_12.9ubuntu3_all.deb...
Estrazione di crossbuild-essential-arm64 (12.9ubuntu3)...
Configurazione di libconfig-inifiles-perl (3.000003-1)...
Configurazione di libyaml-perl (1.30-1)...
Configurazione di cross-config (2.6.18+nmu2)...
Configurazione di libxml-simple-perl (2.25-1)...
Configurazione di libconfig-auto-perl (0.44-1.1)...
Configurazione di libdebian-dpkgcross-perl (2.6.18+nmu2)...
Configurazione di dpkg-cross (2.6.18+nmu2)...
Configurazione di crossbuild-essential-arm64 (12.9ubuntu3)...
Elaborazione dei trigger per man-db (2.10.2-1)...

aresuser@jetson:~/Scrivania/Android/emu/external/qemu$ python3 android/build/python/cmake.py --noqtwebengine --
noshowprefixforinfo --target linux_aarch64

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Leftover arguments: ['--noqtwebengine', '--noshowprefixforinfo'], are ignored and will soon be removed.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
cmake.py --noqtwebengine --noshowprefixforinfo --target linux_aarch64
Running Clean: Deletes the destination directory.
Running Configure: Runs the CMake Ninja generator.
Configure target: linux-aarch64, native compilation
Run: /home/aresuser/Scrivania/Android/emu/prebuilts/cmake/linux-x86/bin/cmake -B/home/aresuser/Scrivania/Android/emu/external/qemu/objs -G Ninja -DOPTION_CRASHUPLOAD=NONE -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/home/aresuser/Scrivania/Android/emu/external/qemu/android/build/cmake/toolchain-linux-aarch64.cmake -DOPTION_SDK_TOOLS_BUILD_NUMBER=standalone-0 -DPython_EXECUTABLE=/usr/bin/python3 /home/aresuser/Scrivania/Android/emu/external/qemu -DOPTION_SDK_TOOLS_REVISION=35.3.2 -DOPTION_TEST_LOGS=/home/aresuser/Scrivania/Android/emu/external/qemu/objs/testlogs in None
x86_64-binfmt-P: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
Build failure due to /home/aresuser/Scrivania/Android/emu/prebuilts/cmake/linux-x86/bin/cmake -B/home/aresuser/Scrivania/Android/emu/external/qemu/objs -G Ninja -DOPTION_CRASHUPLOAD=NONE -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/home/aresuser/Scrivania/Android/emu/external/qemu/android/build/cmake/toolchain-linux-aarch64.cmake -DOPTION_SDK_TOOLS_BUILD_NUMBER=standalone-0 -DPython_EXECUTABLE=/usr/bin/python3 /home/aresuser/Scrivania/Android/emu/external/qemu -DOPTION_SDK_TOOLS_REVISION=35.3.2 -DOPTION_TEST_LOGS=/home/aresuser/Scrivania/Android/emu/external/qemu/objs/testlogs Status: 255 != 0

@xavetar
Copy link
Author

xavetar commented Sep 18, 2024

x86_64-binfmt-P

I think a machine with x86_64 architecture is needed for cross-assembly to aarch64. Android Emulator does not natively support building on aarch64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment