How to run a Linux program on Android. Installing the Genymotion Android emulator for Linux. Creating a virtual machine with 100% OpenGL support

Also, not long ago, one developer found a way to run Android applications on a PC in the Chrome browser.

The chromeos-apk script by Vlad Filipov, together with the ARChon Android Runtime extension, made it possible to run Android applications in the Chrome browser on Windows, Mac and Linux PCs.


Applications do not run very smoothly through the extension. And you should completely forget about trying to run Dead Trigger 2 or any other demanding games.

Also, since this is an unofficial repack of the official extension and it runs outside of Chrome OS, system functionality (such as a web camera, speakers, etc.) will not be available.

This instruction is quite experimental and therefore does not provide any guarantees. You can satisfy your curiosity and follow it, but you shouldn’t have high hopes.

How to run Android applications on Linux

In order for you to be able to run Android applications on Linux via Chrome, you naturally need the Chrome browser itself. The version must be 37 or higher.

Already installed required version Chrome? Then you can install the developer version via the command line:

sudo apt-get install google-chrome-unstable

Now you need to install a custom extension - unofficial and unrecognized by Google or Chromium - Android Runtime created by Vlad Filippov. It is very different from the official version, mainly in that it can be installed on PC versions of the browser.

Download ARChon v1.1 (for 32bit Chrome) from GitHub Download ARChon v1.1 (for 64bit Chrome) from GitHub

Once the extension is downloaded, you will need to unzip the contents into your ~/Home folder.

Now we install ARChon. Open Google Chrome and go to the menu. Select the Tools > Extensions section and, at the top, check the ‘Enable developer mode’ checkbox.

And finally, click the ‘load unpacked extension’ button and select the folder that you previously placed in the ~/Home directory.


The extension itself won't do all the work on its own, so you'll have to make sure your Android app is compatible with the extension.

There are several ways to do this: manually, on your PC, or using a free Android application. We'll tell you how to do this manually, but BTW! There is also a program for PC called 'Twerk', as well as Archon Packager tool for mobile devices.

To convert APK files manually - something you don't have to do if you use one of the apps mentioned above - you will need to install 'chromeos-apk' via the command line JavaScript utility. All this can be done in the Node Packaged Modules manager (npm).

First do:

sudo apt-get install npm nodejs nodejs-legacy

Are you using Ubuntu 64? Then pour this also:

sudo apt-get install lib32stdc++6

Now run the command to install the script itself:

npm install -g chromeos-apk


OK it's all over Now. Head to Google and find the APK of the app you want to try, but remember that not all Android apps will run, and those that do may be buggy or laggy.

operating system Android is somewhat different Linux a system that runs cross-platform applications written in the language Java, in the environment virtual machine ART (Android Runtime) in new versions and Dalvik in the old ones.

We will not delve into the intricacies of the architecture and interaction of system components, the main thing to know is Android based on Linux, but has some differences.

Today phones android They have firmly entered our lives and many people actively use them. Along with the devices themselves, mobile applications are also becoming popular. Sometimes they can completely replace simple functions PC- viewing mail, playing music, movies, reading news.

Surely someone wondered whether it is possible to use mobile applications android on PC? Answer - Can, but with some restrictions.

The article discusses the question of how to do this. Whether this makes sense, everyone decides for themselves.
The description of the process is not a call to immediately do this in your operating system and is given within the framework of the thesis " just for fun"that is, for the sake of interest.

We will need:

operating system LINUX(distribution version is not important)

Browser Google Chrome 64 bit (Chromium and chromium browsers like Opera, Vivaldi, Yandex etc unsuitable),

32 bit assemblies are no longer produced.
- extension For Google Chrome ARChon.

IN linux unable to run file directly apk applications android, even if the extension is installed ARChon.

To run it, you need a special way to convert And install Also as an extension ARChon.
There are several ways to convert applications. You can choose the one that works best for your conditions.

1 . By using chromeos-apk(the most reliable).
Install Node.JS
Use your package manager.
Warning! IN Ubuntu repository Node.JS does not work because the developer stopped supporting it.
Distributions based on Arch perfectly placed from AUR.
Next we put chromeos-apk also from AUR.

We do it ourselves transformation APK file team in terminal:

Chromeos-apk /path/to/.apk

Who not Arch distribution, then we use other methods described below.

3 . Using the extension Twerk For Google Chrome from Google Web Store

4 . program apk2archon in python. github link

You can read more on the 4pda website, which describes in detail how to change size application, what parameters to set at startup.

Installed applications can be found in application menu. In chapter " Chrome apps".

By editing you can change launch icon.

The extension applications themselves will be stored in folders like com.twitter.android.android, you can copy the desired icon to this folder icon.png(to launch the application and display in the menu).

Good day, dear readers. Today we will figure out how to install the Genymotion Android emulator on the Linux operating system (in this case, Linux Mint 17.1).
Conventionally, the entire process “from start to finish” can be divided into three stages.
1. The first stage is extremely simple - you need to install VirtualBox (if you haven’t installed it before). As usual, you can do this in two ways - in the Terminal or in the Program Manager. In my case, the second method was chosen, so there is no point in giving explanations; the photo below shows the already installed program in the Manager:

Picture 1. Installed program VirtualBox

2. At the second stage, you need to register on the website geniusmotion. To do this we go to registration page and fill out a simple registration form. After which, upon completion of registration, the following page opens:

“Buy” should not confuse you :) Let’s proceed as in the photo below:

Figure 3. Downloading the free version of the program

Select the 32-bit version.

Figure 4. Selecting the program version

After the file has been automatically downloaded, you can begin installing the Genymotion application. To do this, launch the terminal and go to the directory (folder) in which the downloaded file is located. In this case, the file was moved to Home for convenience and clarity. In this case, simply execute the command

chmod a+x ./genymotion-2.6.0-linux_x86.bin

Figure 5. Changing file permissions

and launch it for execution with the command

./genymotion-2.6.0-linux_x86.bin

During the installation process, answer the question in the affirmative and upon completion of the installation, the terminal window will look like this:

Figure 6. Launching the program installation file

This means that the program has been successfully installed on your computer and the menu looks like this:

Figure 7. Installed Genymotion program

After this, we launch the program and create a new virtual device. As you can see, you can choose the Android version, as well as the device model. We recommend choosing an Android version no higher than 5.0 (if in the future the device will be intended not only for testing its own applications, but is also planned to be used as a full-fledged device with access to Google services). For example, HTC One (Android 4.2.2) was selected. Installation of the device is intuitive and does not require detailed consideration. After it is created and launched, we move on to the final stage - installing Google services.

3. First of all, download the Genymotion ARM Translation v1.2 file (located in the general archive at the end of the article). Then this file just drag it into the emulator window (archive, without unpacking). The window should light up with a pink frame at this time. After which the following message will appear in the window:

Figure 8.

And then after some time confirmation will be required, for which we simply click “OK”:

If the installation was successful, at the end you will see a window with the following notification and a request to restart the device:

Figure 10. Successful installation of the archive and restart of the device

Close the emulator and start it again. Next we perform completely similar actions, but with one of the gapps-android_x.x files (all necessary files are in the general archive at the end of the article).

The set of Google applications you need is selected according to the Android version. We also drag the unpacked archive into the emulator window and restart the emulator after the installation is complete.

After the restart, the following window will appear, in which we log in (or, if we don’t have an account, register a new one) and our device is ready for use:

Figure 11. Ready-to-use device

Figure 12. Full operation of the Google service

As a result, applications from Google appeared in the menu and you can fully use the emulator like any Android device :)

You can download all the necessary installation files .

Previously, I somehow came across material about the ARC Welder extension for the Google Chrome browser, with which you can install and use Android applications in apk format, that is, you have an apk format file on your computer, you launch the ARC Welder extension where you are asked to select this particular file from your computer, and then you can install and use.

I read online how previous users Ubuntu Linux We used this extension and installed a client for Twitter or VKontakte in Ubuntu, it worked out very well, you communicate with friends and Ubuntu-style messages similar to VKontakte appear in the lower right corner of the monitor. Somehow I decided to install this extension in Chrome version 46, but alas, as written, the extension has already stopped working stably and is only available for versions 37 or higher. I had no desire to demolish my 46 version.

  • I decided to look online for an alternative to an Android emulator for the Linux platform, the choice is certainly small and there is little to choose from, but I still found one emulator called Genymotion, what is it like, you ask.

Genymotion is a very fast Android emulator that contains complete and customized Android images (x86 with OpenGL hardware acceleration), ideal for testing applications if you are developing applications for the Android platform. Previously, this project worked in one common name called AndroidVM, after it was disconnected it grew into something more and became known as Genymotion, which has a new player design, installer and many other goodies.

According to the project's developers, their goal is to try to completely replace Google's Android emulator not only for Android developers, but also for those users who make demos of Android applications.

Genymotion is a cross-platform emulator and is available for Linux, Windows and Mac OS X, that's not all, it requires VirtualBox to be installed on your computer to work. Genymotion is very connected with virtualbox, since when you add a virtual machine, integration occurs and the virtual machine is created automatically in VirtualBox, for testing applications or simply to install any of the applications in any of the smart phones you like, any of the available models in the list, we need add a device and then simply press the button to load the android kernel for this module.

  • Everything happens very quickly, I only tested for the Google Nexus 4 model, it loaded like 150 or 160 meters, everything installed quickly, what is required to launch a virtual device for testing? You need to first launch VirtualBox, then you will see a new device in the list, this will be the device that we added to Genymotion, presses the "Launch" button. After the machine starts and you see that the kernel is working, simply minimize the application window and select the device model that we added to Genymotion and press the “Play” button, then the android will start and you can start testing.

First of all, I described the process of how the application works, now let’s move on to how and where to download the package to install the application Genymotion on Ubuntu Linux. The first thing you need is to go to the official website of the developers and register:

As you can see, when registering, I chose that I am, as it were, a 1-user tester and there is no need to write anything more, then you will receive a message confirming registration by email, confirm, then select the Free tariff on the site and follow the link - https://www. genymotion.com/#!/download in the column we select the latest Linux we need, here you will see two packages for both 32-bit and 64-bit.

The application is downloaded in bin format, there is no complexity here and everything is very easy to install. After downloading the bin format file for your architecture, go to the terminal and run the following commands:

cd /home/linux/Downloads/
sudo chmod a+x genymotion-2.5.2_x86.bin
sudo ./genymotion-2.5.2_x86.bin

After executing these commands, we will give read and launch rights and start installing the application. Of course, your file name may be slightly different if you are downloading it for a different architecture, but the installation principle is the same. Once the installation starts, you will see the following message:

:~/Downloads# ./genymotion-2.5.2_x86.bin

Installing to folder . Are you sure? y
- Trying to find VirtualBox toolset……………….. OK (Valid version of VirtualBox found: 5.0.10r104061)
- Extracting files……………………………………. OK (Extract into: )

Installation done successfully.

You can now use these tools from :
- genymotion
- genymotion-shell
- gmtool

  • You will have something similar where you just have to enter Y (Yes), that is, we agree to the installation, to a large extent this is not even an installation, the bin format file contains an archive with folders for the application to work, after executing the command above , the files will be unpacked normally into the Downloads directory. After unpacking you will see a folder called " geniusmotion".
  • By going to which you will find a file called genymotion, but this is an executable file, double-click on the genymotion file and the application will start.
  • After we see the application interface, in the window that opens we are immediately prompted to add a virtual device for testing, I am of course already authorized and this is immediately displayed to me, for this you will need to log in to the program interface and only then can you add virtual devices for testing.
  • Pressing a key Yes, we will see a large list of proposed device models for creating a virtual machine in Virtual Box, select the one that interests you.
  • Above there are filter tabs and you can also select any of available versions Android for the device or select a specific device module and filter as you need. We have selected the device we are interested in, select it by clicking on it, then press the button " Next".
  • The image of the virtual device is loaded, press the button " Finish", then let's run VirtualBox and check, our device should already be added there.
  • We see that the new device has been added automatically as it should be, click on the " Launch" and wait for the kernel of our virtual device to start.
  • As we can see, the kernel has started, everything is fine, we can minimize the virtual window without closing it, now let's go to the Genymotion application interface where we select our added machine and press the button " Start", and wait until our virtual device starts Google Nexus 4, in my case, you can add another one and launch yours accordingly.

So we launched our added device and we can start testing, as you can see from the screenshot above, we are immediately asked to change the localization, that is, switch to the interface language that is convenient for us, we quickly switch and work for our own pleasure. Of course we do not forget that we are free plan and not all delights are available to us.

I guess that’s all, get used to it, there will be questions, ask them in the comments to the material.

Today we will talk about running Android applications on a Linux system without using an emulator.

Anbox

  • What is Anbox?
  • Application Manager
  • How is it different from Shashlik
  • How Anbox works

What is Anbox?

Unbox is something like Vine, only for launching Android applications. Unbox uses containerization technology, which allows you to run applications on the hardware and core of the host with performance comparable to native ones. To run applications, LXC containers and (for now) kernel modules compiled via DKMS are used.

It differs from other emulators in its good performance, open source (ZhPLv3), presence under the ontopic and good integration with the host. Well, the host integration is definitely superior to any VM solutions and almost as good as ARC.

Immediately after launch, you will see on the screen a simple “application manager” written specifically for Anbox. There are a lot of applications here: standard gallery, calendar, settings, etc., but there is no market. And so the first thing you ask is: how to install applications on Anbox?

Application manager in Anbox

And this is where things get interesting. Anbokh developers do not have the right to include the market and any other Google software, including Google services, in the delivery of their non-emulator, until their “device” passes certification. The device cannot pass certification - there will be no market.

But! In Anbox, debug mode is enabled by default with using ADB(which in standard Android is turned on in the settings for developers, where you still need to get to), so you can install the application using it. You can install ADB itself like this:

$ sudo apt-get install android-sdk-platform-tools // Ubuntu $ sudo pacman -S android-tools // Arch Linux

Now comes the fun part: you need to find and download the APK package of the desired application. You can use the apkpure website for this. Then all that remains is to execute the following command (example for FX File Explorer):

$ adb install ~/Downloads/File Explorer_v5.1.1.0_apkpure.com.apk FX File Explorer

Ready! Install the apps, have fun, see you later. Just kidding, there are actually a lot of pitfalls. For example, immediately after installing Anbox, I decided to test how Opera Mini works in it, the same browser that can quickly display pages, even if the Internet reaches you via pigeon mail. After all, it is not available for the desktop.

As a result, this is what appeared on the screen:

$ adb install ~/Downloads/Opera Mini fast web browser_v24.0.2254.115689_apkpure.com.apk Failed to install /home/j1m/Downloads/Opera Mini fast web browser_v24.0.2254.115689_apkpure.com.apk: Failure

The explanation for this is simple: most of Opera Mini code is written in C++, which is compiled into a binary for the ARM platform. And since our machine has an x86_64 architecture processor, Android carefully nailed down the application at the installation stage so that we wouldn’t suffer trying to understand why it doesn’t work.

In fact, the market is full of similar applications, and you will encounter architectural incompatibilities quite often.


Second interesting feature launching applications in separate desktop windows: not every application is ready to accept the fact that its face will now be tightly squeezed or stretched. Most modern applications will behave correctly in this case - Google took care of this when preparing to implement support for floating windows in Android 7.0. But with old software, difficulties may arise, although usually everything ends with a window of a fixed size.

Well, third. Unbox, in Shakespearean language, is alpha software, that is, the guys seem to be telling us: everything will be bad and unstable, and you can forget about such things as support for determining coordinates, a camera and a microphone. Moreover, in some cases you may forget about the Internet, and the session manager will crash from time to time and will have to be restarted.


But! Anbox correctly determines the current battery level, size random access memory and even hard drive(more precisely, the /home partition). And in general it works quickly and does not make you want to tear it down. The amount of RAM consumed is only 448 MB when the application manager is running.
Applications see the entire disk

FAQ Anbox

How to press the back button and scroll pages?

The Back button is emulated using Esc. The keyboard can also be used to navigate the application (Tab and arrows). Scroll either with the wheel or by holding the left mouse button and moving up and down.

Can Anbox be used to run projects in Android Studio?

Yes! Moreover, no additional steps need to be taken for this. It is enough to select a device with a name like emulator-6663 when starting the project.

Is it possible to access the file system of a running Android from Linux?

Yes, it is located in the /var/lib/anbox/rootfs directory, but it is read-only. But you can view the contents of private application directories (data/data).

Can I install an app store?

Theoretical possibility to install Google Play Store exists. To do this, you need to parse the Android file system image and integrate GApps into it. However, it is much easier to install Yandex.Store or any other third-party market. Plus activate installation from third-party sources: Settings → Security → Unknown sources.

How to disassemble the Android Anbox image?

Very simple:
$ sudo apt-get install squashfs-tools // Ubuntu $ sudo pacman -S squashfs-tools // Arch Linux $ unsquashfs -f -d /to/unpack /var/lib/anbox/android.img

Is it possible to use another Android image, such as CyanogenMod?

No. There are two reasons why this cannot be done. First, it must be an Android build for x86_64. Second, this build must include specific Anbox modifications.

How Anbox differs from Shashlik

Shashlik runs every application in an emulator. In other words, when you click on the application icon, the emulator starts, it contains a stripped-down Android environment, and only then the application starts. Anbox is much more lightweight and performant.

How Anbox works

Anbox is based on a very simple idea: if Android is a virtual machine running on top Linux kernels, then why not try running Android applications surrounded by a regular Linux distribution. This is an obvious idea, and one that has occurred to many developers since the x86 port of Android appeared. Some programmers tried to implement it by placing the Android environment in a chroot, but things did not go beyond semi-working concepts (example: ).

It took Anbox developers a year and a half to bring the project to completion. They were able to integrate Android applications into the Linux desktop, ensure almost complete compatibility, and most importantly, make it all work quickly, without glitches and without requiring many steps to configure.

The Android environment itself (based on the latest Android 7.1.1, by the way) is locked in a sandbox, controlled using namespaces technology, the same one that underlies Docker. Namespaces completely cut off the environment from the Linux distribution environment, and all work with the equipment occurs through the anboxd daemon. To display images from 3D applications, a special OpenGL ES → OpenGL translator, borrowed from the official Android emulator, is used.

The Linux kernel also had to be modified, or rather, modules with the implementation of binder and ashmem were added to the Anbox kit, with the help of which system components (IPC) interact in Android. Before launching, Unbox loads modules into the kernel and adds a udev rule to set the correct access rights to the /dev/binder and /dev/ashmem devices.

Anbox places each application in its own window using a modified hwcomposer composite manager, which Android uses to overlay graphic layers. Hwcomposer requests all layers of each application and gives them to Anbox, which then creates individual windows for individual applications.

All these technical solutions make Unbox a truly fast, easy-to-use, and resource-efficient “emulator.” Including in 3D applications.

Anbox consists of two components: container manager and session manager.

Container manager manages sandboxes with the Android environment running inside. Its task is to start the Android system correctly, maintain its operation and shut it down correctly.

Session manager, in turn, is responsible for Android communication within the sandbox and with the main Linux system. Its job is to respond to application launch requests and distribute them across different windows.

In general, launching an Android application using Anbox looks like this:

  1. The binder and ashmem modules are loaded into the kernel.
  2. The container manager is launched, which deploys a sandbox with Android inside.
  3. The session manager starts, it launches the Android environment.
  4. The user issues a command to launch the application, which is accepted and processed by the session manager.
  5. The session manager is waiting for a command.

Steps 1–4 prepare Anbox and run it once, usually when the system boots.

This architecture makes it possible to launch applications almost instantly due to a small (about 400 MB) memory overhead in idle mode.


conclusions

Without a doubt, Anbox deserves attention. Yes, it has compatibility problems, it can't work with your camera and microphone, it crashes. But this is an alpha version, and for an alpha it works great.

Similar articles

Advertising on the website