Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to run Android Application in Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to run Android applications in Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to run Android applications in Linux.

Overview

Anbox uses Linux namespaces (user, pid, uts, net, mount, ipc) to run a complete Android system in a container and to provide Android applications on any GNU Linux-based platform.

The Android in the container cannot directly access any hardware. All hardware access is made through the anbox daemon on the host. We reuse GL and ES in Android implemented by QEMU-based simulator to accelerate rendering. The Android system in the container uses different pipes to communicate with the host system and sends all hardware access commands through it.

For more details, please refer to the following documentation:

Overview of Android hardware OpenGL ES Simulation Design

Android QEMU express pipeline

Android's "qemud" multiplex daemon

Android qemud service

Anbox is currently suitable for desktop use, but it is also used on mobile operating systems such as Ubuntu Touch, Sailfish OS, or Lune OS. However, since the mapping of Android programs is currently only for desktop environments, additional work is required to support other user interfaces.

The Android runtime environment comes with a minimum custom Android system based on the Android open source project image. The image used is currently based on Android 7.1.1.

Installation

Currently, the installation process includes some steps to add additional components to the system. These include:

Enable non-distributed out-of-tree kernel modules for binder and ashmen.

Use udev rules to set the correct permissions for / dev/binder and / dev/ashmem.

You can start the Anbox session manager as a startup task for a user's session.

To make this process as simple as possible, we bind the necessary steps in a snap (see https://snapcraft.io), which is called "anbox-installer". This installer performs all the necessary steps. You can install it by running the following command on all systems that support snap.

$snap install-classic anbox-installer

In addition, you can download the installation script with the following command.

$wget https://raw.githubusercontent.com/anbox/anbox-installer/master/installer.sh-O anbox-installer

Please note that we do not support all but Linux distributions. Please refer to the following section for supported distributions.

Run the following command to install.

$anbox-installer

It will guide you through the installation process.

Note: Anbox is currently in pre-alpha development state. Don't expect it to have all the features you need in a production environment. You are bound to make mistakes and collapse. If you encounter them, please do not hesitate to report them!

Note: Anbox snap currently has no constraints at all, so it can only be obtained from edge channels. The right constraints are what we want to implement in the future, but because of the nature and complexity of Anbox, this is not a simple task.

Supported Linux distributions

Currently, we officially support the following Linux distributions:

Ubuntu 16.04 (xenial)

Untested but possibly supported:

Ubuntu 14.04 (trusty)

Ubuntu 16.10 (yakkety)

Ubuntu 17.04 (zesty)

Install and run the Android program

Build from source code

You don't need to know much about building the Anbox runtime, so we use cmake as the build system. You should already have the following build dependencies in your host system:

Libdbus

Google-mock

Google-test

Libboost

Libboost-filesystem

Libboost-log

Libboost-iostreams

Libboost-program-options

Libboost-system

Libboost-test

Libboost-thread

Libcap

Libdbus-cpp

Mesa (libegl1, libgles2)

Glib-2.0

Libsdl2

Libprotobuf

Protobuf-compiler

Lxc

On Ubuntu, you can install all dependencies with the following command:

$sudo apt install build-essential cmake cmake-data debhelper dbus\ google-mock libboost-dev libboost-filesystem-dev libboost-log-dev\ libboost-iostreams-dev libboost-program-options-dev libboost-system-dev\ libboost-test-dev libboost-thread-dev libcap-dev libdbus-1-dev\ libdbus-cpp-dev libegl1-mesa-dev libgles2-mesa-dev libglib2.0-dev\ libglm-dev libgtest-dev liblxc1 libproperties-cpp-dev libprotobuf-dev\ libsdl2-dev lxc-dev pkg-config protobuf-compiler

Then build the Anbox with the following command:

$mkdir build $cd build $cmake.. $make

A simple command will install the necessary binaries into your system, as follows.

$make install

If you want to build anbox snap, you can follow these steps:

$mkdir android-images $cp / path/to/android.img android-images/android.img $snapcraft

As a result, there will be a .snap file that you can install on systems that support snap.

$snap install-dangerous-devmode anbox_1_amd64.snap

Run Anbox

To run Anbox from a local build, you need to know a little more. Please refer to the Runtime steps documentation.

Document

You can find additional documentation on Anbox in the subdirectory of the project source code.

If you are interested, you can take a look:

Run-time steps

Build an Android image

Report bug

If you find an Anbox problem, please submit bug.

Get in touch

If you want to contact developers, you can add # anbox's IRC channel to FreeNode.

Copyright and license

Anbox reuses code from other projects such as the Android QEMU simulator. These items are available in an external / subdirectory with a license declaration.

The anbox source code itself, if other licenses are not declared in the relevant source code, the default is the GPLv3 license.

At this point, I believe you have a deeper understanding of "how to run Android applications in Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report