- Пишем и собираем приложения для Android в linux консоли
- Введение
- Железо
- Операционная система
- Установка пакетов
- Настройка adb
- Постановка задачи
- Создание подписи
- Манифест
- Layout
- Исходный код приложения
- Скрипт для сборки
- Сборка и установка
- Заключение
- Установка и запуск Android-приложений на Linux
- Top Android Emulators to Run and Test Android Apps on Linux
- 1. Anbox
- 2. Genymotion
- 3. Android-x86
- 4. Android Studio (Virtual Devices)
- 5. ARChon
- 6. Bliss OS
- Wrapping Up
- 5 Best Android Emulators For Linux [2021 Edition] – Free And Paid
- 5 Best Android Emulators For Linux (2021)
- 1. Android-x86
- How To Install Android-x86 On Linux?
- How To Install And Run Android Apps In Android-x86?
- 2. AVD (Android Virtual Device)
- How To Install Android SDK On Linux?
- How To Install And Run Android Apps In AVD?
- 3. Genymotion
- How To Install Genymotion On Linux?
- How To Install And Run Android Apps In Genymotion?
- 4. Bliss OS
- How To Install Bliss OS On Linux?
- How To Install And Run Android Apps In Bliss OS?
- 5. Anbox
- How To Install Anbox On Linux?
- How To Install And Run Android Apps In Anbox?
- Want more Android Emulators?
Пишем и собираем приложения для Android в linux консоли
В данной статье я покажу как можно собрать apk файл в Ubuntu используя лишь
утилиты командной строки.
Обычно для создания приложений для Adroid используется Android Studio. Но для сборки небольших программ можно обойтись командной строкой. Например, когда ресурсы компьютера ограничены и ваше приложение очень простое.
В качестве постоянной среды разработки это, возможно, не очень удобно, но если вам нужно
иногда собирать какие-нибудь мелкие утилиты — это в самый раз.
Введение
Разработка под Android не является основным направлением моей деятельности, я иногда делаю какие-то небольшие приложения для своих нужд.
Раньше я использовал QPython, но он достаточно тяжел и неудобен в работе. Поэтому я перешел к разработке нативных программ. Даже при поверхностном знании Java
это не составляет больших трудностей.
Данное руководство в большой степени базируется на этом документе: Building an Android App
from the Command Line. Кому интересны подробности, обращайтесь к первоисточнику.
Похожая статья: Пишем, собираем и запускаем HelloWorld для Android в блокноте уже встречалась на этом ресурсе, но в ней было рассмотрена разработка в Windows.
Здесь же я рассмотрю, как можно собрать приложение в linux.
Железо
Тестирование проводилось на стареньком нетбуке с процессором Атом, 1Гб ОЗУ
и 8Гб SSD диска.
Операционная система
Я тестировал приложение на Ubuntu 17.04. Начиная с Ubunu 16.04 android-sdk можно установить через пакетный менеджер.
В принципе, тот же SDK можно
скачать с сайта.
Качать файл из раздела ‘Get just the command line tools’
По сути это не сильно меняет процесс, но через пакетный менеджер все гораздо проще.
Разница будет лишь в путях и установке дополнительных пакетов «android-platform».
Установка пакетов
Итак, приступим к установке.
Будет установлено большое количество пакетов, включая Java.
Далее, в зависимости от требуемой версии Android, необходимо установить нужную
версию пакетов. Для lolipop 5.1 необходимо ставить:
Так же необходимо установить дополнительный пакет.
Если вы планируете устанавливать apk-пакет через adb, то необходимо немного дополнительных настроек.
Настройка adb
С помощью lsusb найти подключенное устройство
И создать файл с правилом:
В файл добавить одну строку:
Здесь «1782» взято из вывода lsusb.
После подключения через adb, на устройстве необходимо подтвердить соединение.
Теперь все готово к работе.
Постановка задачи
Приложение, которое будем собирать немного сложнее, чем ‘Hello world’.
- Требуется по нажатию кнопки взять строку из буфера обмена.
- Вырезать подстроку
- Записать подстроку обратно в буфер.
- С помощь Toast вывести подстроку или сообщение об ошибке.
В общем-то все просто.
Я подготовил пример который возьмем за основу.
Создание подписи
Сначала создадим ключ для подписи файла:
Это нам пригодится позже.
Манифест
Здесь указываем имя приложения в атрибуте «android:label». Так же приложение будет использоваться свою иконку, она указана в атрибуте «android:icon». Сама иконка лежит в каталоге «res/drawable-mdpi» файл «icon.png». В качестве иконки можно взять любой небольшой png файл.
Layout
Файл с расположением элементов находится в каталоге «/res/layout/».
В него можно добавлять виджеты, если вы захотите расширить функционал.
Исходный код приложения
Исходный код приложения находится здесь «java/ru/kx13/extractvidid»
Код весьма прост и примитивен, но этот шаблон можно использовать в других приложениях.
Скрипт для сборки
Я не стал использовать утилит сборки типа make или ant, т.к. весь код находится в одном файле и особых преимуществ это не даст. Поэтому это обычный shell скрипт:
Некоторые замечания по поводу путей.
- По умолчанию, переменная BASE указывает на путь, в который пакетный менеджер сохраняет файлы. Если вы ставите SDK вручную, то путь надо будет изменить.
- Если вы используете версию API отличную от 22, то вам надо подправить переменные BUILD_TOOLS и PLATFORM
Сборка и установка
Для сборки просто запустите
Если все настроено правильно никаких сообщений не будет выведено, а в каталоге «build» появится файл «Extractor.apk»
Теперь надо установить наше приложение
Если все прошло нормально, на устройстве появится новое приложение. Можно запускать и пользоваться.
В общем случае можно перекинуть файл apk на устройство любым удобным способом.
Заключение
Как видно из статьи начать разработку в консоли совсем несложно.
Консольные утилиты позволяют разрабатывать программы при весьма небольших ресурсах.
Источник
Установка и запуск Android-приложений на Linux
Как известно, многие Android-приложения можно нативно запускать на Chrome OS благодаря библиотеке Chrome App Runtime.
С помощью расширений chromeos-apk и ARChon запуск Android APK стал возможен и на других ОС.
В этой публикации я расскажу, как установить произвольное Android-приложение на Ubuntu 14.04.
Исходные инструменты:
- Ubuntu 14.04 LTS;
- Chrome 39.0 (подойдет и другая версия 37+).
Устанавливаем ARChon Runtime
1) Скачиваем и распаковываем ARChon в произвольную дирректорию;
2) Открываем Chrome и включаем Developer mode в chrome://extensions/;
3) Кликаем «Load unpacked extension» и устанавливаем распакованный ARChon.
Далее необходимо подготовить архив APK для установки.
Устанавливаем chromeos-apk
1) Для Ubuntu прежде всего нужно установить библиотеку lib32stdc++6:
2) chromeos-apk можно установить с помощью менеджера пакетов npm (поставляется вместе с node.js).
3) Сейчас можно установить непосредственно chromeos-apk:
Теперь все готово к распаковке APK.
Подготавливаем APK с помощью chromeos-apk
1) Для распаковки APK-архива выполняем:
2) Теперь у нас есть Chrome-APK расширение, и все что нужно — загрузить (chrome://extensions/) и запустить его.
UPD: полезные ссылки от sequence
ARChon Packager: создает архивы для archon из установленных в телефоне приложений.
twerk: расширение хром, сильно облегчает конвертацию apk.
Источник
Top Android Emulators to Run and Test Android Apps on Linux
Last updated July 21, 2021 By Ankush Das 7 Comments
Android is built on top of a heavily customized Linux kernel. So, running mobile apps on Linux makes sense using an Android emulator.
While this is not something new that you can do on your Linux machine, it is a feature more in demand after Windows introduced the ability to run Android apps in 2021.
Not just limited to using apps, some of the Android emulators can also come in handy for development and testing.
Hence, I have compiled a list of the best emulators that you can use to test or run Android applications/games on Linux.
1. Anbox
Anbox is a pretty popular emulator that lets Linux users run Android apps. Probably this is what Deepin Linux utilizes to make help run Android apps out of the box.
It isolates the Android operating system from the host using a container, which also lets them make the latest Android version available to use.
Android apps running will not have direct access to your hardware—which is a good security decision.
Unlike some of the other options here, Anbox does not technically need an emulation layer to make Android work. In other words, it is as close to a native Android experience on your Linux system.
For this reason, it may not be the easiest option available. You cannot just use the Google Play Store to install applications, you need to utilize Android Debug Bridge (ADB). All you need is the APK file of an app to install and use it.
2. Genymotion
Genymotion is an impressive solution tailored for testing and development.
It is not a free and open-source option. They provide virtual Android experiences as a service through the cloud or a desktop client that is independent of Android Studio.
You can simulate a variety of hardware configurations and Android versions to create a virtual device for testing. It also gives you the ability to scale up and has multiple Android virtual devices running for extensive tests.
It can help you test how file uploading works in your app, impacts battery, performance, memory, and so on.
While it is a premium solution mostly for professionals, it does support the latest Linux distributions that include Ubuntu 20.04 LTS.
3. Android-x86
Android x86 is an open-source project to make Android run on a PC with 32-bit support.
You can choose to install it using a virtual machine manager on your Linux system or directly try it on your PC.
Official installation instructions are available if you need to go ahead.
Unlike some other options, it is a simple emulator that tries to work on a PC with no fancy features.
4. Android Studio (Virtual Devices)
Android Studio is a full-fledged tool for development and testing. Fortunately, with the support for Linux, you can use it to emulate the Android experience for experiments if you need to.
You just need to create an Android Virtual Device (AVD) that you can configure and then simulate as an emulator.
There are good chances to find support for some of the latest smartphones, TVs, and smartwatches as well.
It needs a certain learning curve to be able to pull it off, but it is free and completely open-source.
5. ARChon
An interesting solution is an Android emulator that you can use in Linux and any other platform.
It helps run Android apps on Chrome OS or with Chrome browser on any operating system. Unlike some others, you may not get a complete Android experience but only the ability to run Android apps.
You just have to unpack the runtime and load it into Chrome extensions. Next, add the app you want to use by downloading the APK file onto it.
6. Bliss OS
Bliss OS is yet another open-source project, similar to Android x86 that aims to make Android run on PC.
Unlike Android x86, it gives more compatibility options by supporting both 32-bit and 64-bit architectures. Also, you can download the compatible file as per your processor.
It is actively maintained and supports the latest Android versions available in the market.
Wrapping Up
While you will find several Android emulators available for Linux, they may not replace a full-fledged smartphone experience.
Every emulator comes with a set of features along with a specific purpose. Choose the one that you need!
Have you tried Android emulators yet? What’s your favorite emulator that you have used in Linux? Feel free to let me know in the comments down below.
Like what you read? Please share it with others.
Источник
5 Best Android Emulators For Linux [2021 Edition] – Free And Paid
The immense popularity of Android is the reason why developers love it so much. However, as a consumer of these apps, it’d not be feasible to run resource-heavy apps on smartphones that you can barely make a call with. And here’s where Android emulators come to the rescue.
Android emulator is an application that acts as a real Android device. You can install it on your desktop computer to run Android applications. The best part of it is, it can also run on a low-powered PC. Hence, we’ve compiled a list of the 5 best Android emulators for Linux operating systems.
5 Best Android Emulators For Linux (2021)
- Android-x86
- AVD (Android Virtual Device)
- Genymotion
- Bliss OS
- Anbox
Since there are not many dedicated Android emulators for Linux, we’ll be installing some x86 Android projects like Bliss OS. For that, you’ll need to install VirtualBox first. If you don’t know how to install VirtualBox, do make sure to check out our How to install VirtualBox article.
1. Android-x86
Price: Free
Android-x86 is one of the best alternatives to other phone emulators if you want to run Android games or applications. Instead of installing on top of a particular OS, it has a separate ISO to boot as a standalone Android operating system.
As the name suggests, Android-x86 targets the x86 architecture. You can also run it without installation using the Live CD option. By default, it starts with an interface similar to an Android application launcher, but you can also change it to a Windows-style desktop.
Furthermore, you can also download themes from the Google Play Store. Android-x86 provides full support for Google services.
Key features of Android-x86:
- Wi-Fi and Bluetooth support with GUI
- Bluetooth, G-sensor support
- External storage automount support.
- Theme support to GRUB-EFI
- Preinstalled terminal emulator
Another thing that makes this Android emulator more reliable is timely software updates. Recently, the first stable Android-x86 release based on Android Pie 9.0 brought various new features such as experimental Vulkan support for newer Intel and AMD GPUs.
How To Install Android-x86 On Linux?
To install the Android-x86 OS on your Linux desktop, you need to download the ISO or rpm file from here.
Booting using ISO
Create a bootable USB stick using ISO. But before that, I would recommend checking the connected USB device name by running the command:
It will display all the devices attached to your system. You must note down the device name and include the same in the command given below:
where sdX is the device name of your USB drive.
Now, restart the system, and you’ll get an option in the boot menu.
Booting using RPM
If you have the rpm image, you can run the following command if you’re using a Red Hat-based Linux distribution.
But, if you’re using a Debian-based Linux distro, you can use the alien tool to make USB bootable.
To run Android-X86 Emulator on Arch Linux or any Arch-based distros, you can clone and compile the official package from AUR.
After that, reboot your system and enjoy the Android experience.
Note: For running Android x86 on a current Host system, You can use the QEMU Android emulator.
How To Install And Run Android Apps In Android-x86?
You can go to a pre-installed Google Play Store for running Android applications, where you can search and install any application.
2. AVD (Android Virtual Device)
Price: Free
AVD is one of the cleanest Android copies that emulates an Android device and provides almost all capabilities of a real-world Android device. It comes along with Android Studio IDE that you can also use for application development.
You can even simulate incoming phone calls and text messages, different network speeds, rotation, and other hardware sensors. You can connect external devices using a USB to transfer data or debug an Android application.
Since the Android Studio is the product of Google, you can expect direct support from Google. Also, AVD can be the best choice for developers who want a code editor with extended functionality.
A developer can use the virtual device through its graphical user interface or command line for live testing. Moreover, they can also test Android applications based on augmented reality.
Key features of Android Virtual Device:
- Direct Google support
- Easy testing and debugging
- Navigation gestures
- Screenshots & screen recording
- Virtual scene camera and ARCore
Additionally, you can also create multiple Android emulators for Linux and other devices, such as Android tablets, Wear OS smartwatches, and Android TV devices.
How To Install Android SDK On Linux?
Before creating and running the virtual Android emulator, you first require the Android Studio running on your machine. Since it involves a little long process so I would suggest you follow the official instruction from here.
After completing the installation, you can use the virtual device manager to create multiple Android emulators with the desired configuration.
How To Install And Run Android Apps In AVD?
It has Google services. So, you can create a Google account and install the application from the Play Store.
3. Genymotion
Price: Desktop (starts at $136/yr), Cloud ($0.5/min for PaaS, $0.05/min for SaaS)
If you ever search for the best online Android emulator, I guarantee you that you’ll definitely find one common name, i.e., Genymotion. Genymotion is a commercial product available for both cloud and desktop versions. But one of the reasons I’ve ranked it lower because it’s not open source and free.
But being a proprietary emulator, it provides regular support and security. And If you’re a professional developer, then I would definitely suggest considering it apart from AVD. It also fully supports the Android Studio IDE that developers can use to test and debug Android apps. Not only that, but you also have ADB access to utilize the testing framework securely.
Additionally, Genymotion Android Emulator has built-in support for all functionalities such as cellular, Wi-Fi, GPS, and SD card support.
Key features of Genymotion:
- Wi-Fi & GPS
- Camera capture
- Support Android Studio
- Cloud-based and Desktop virtual device
- SMS & Call
If you don’t want to install Genymotion Desktop, you can also use its Android emulator online to run the application in the browser. Using the Genymotion Cloud, you can enjoy heavy games and apps on a large desktop screen without downloading anything.
How To Install Genymotion On Linux?
Before the installation of Genymotion, first, you need to buy the desktop edition. Or, you can also buy the cloud edition to use its online Android emulator requiring no installation. For pricing information, you can go to the official site for cloud and desktop.
How To Install And Run Android Apps In Genymotion?
Genymotion provides full support for Google services. Hence, you can avail of any Android application and access them through your PC.
4. Bliss OS
Price: Free
Another alternative to the ISO-based Android-x86 that you can also consider is the Bliss OS. It supports booting in either MBR or UEFI mode to run Android applications smoothly on any Linux computer or Tablet.
Apart from normal Android functions, Bliss OS has the best cutting-edge user interface. It includes many options for customization and theming. You can also choose between Desktop or Tablet UI, based on the launcher being used.
Moreover, Bliss OS offers high speed and stability to run popular applications on its free Android emulator. You can even adjust the application size according to your device screen.
Bliss OS is also available as a custom ROM for Android smartphones with unlockable bootloaders. So, if you’re into rooting your android device, do make sure to check it out.
Key features of Bliss OS:
- Polished Design
- Network & Wi-Fi
- Google Play Store
- ARM application
- Available for both Mobile & Tablet
To running ARM & ARM64 based applications, you can try the latest beta version of Bliss OS based on Android 10.
How To Install Bliss OS On Linux?
The installation process of Bliss OS is the same as that of Android-x86. You can download and boot the emulator ISO following the same steps. You can also try the beta version for running Android Pie 10 from here.
How To Install And Run Android Apps In Bliss OS?
Bliss OS also follows the same process of installing an application using Google Play Store. Download the stable version of BlissOS from here.
5. Anbox
Price: Free
Anbox is the Canonical product that also builds the most famous and my favorite Linux distro, Ubuntu. But I am still placing it in the last spot because Anbox does not support Google Play Store.
It is much like a compatibility layer that runs Android applications on any GNU/Linux operating system. Hence, instead of the Play Store, you need to use the ADB tool to install the app using its downloaded APK.
Anbox utilizes the host machine kernel and resources to run the Android OS instead of creating an emulated system. As a result of this, Anbox works fluently and swiftly to run apps on its free Android emulator.
Additionally, Anbox features a unique model of leveraging LXC containers to separate Android OS from the host machine completely. Doing so works more like a virtual machine and makes users feel like they’re using a handheld Android smartphone, making it one of the best Android emulators for Linux.
Key features of Anbox:
- Open-source
- Container-based approach
- Secure and scalable
- APK application support
- Cloud version available
You can also install other mobile OS on Anbox, such as Ubuntu Touch, Sailfish, or LuneOS. Anbox is also the best Android emulator for Kali Linux.
How To Install Anbox On Linux?
For installing Anbox, first, you need to install the software management tool called Snap.
To install snap, run the command:
For the Anbox, run the command given below and enjoy the Android experience on the Linux system.
How To Install And Run Android Apps In Anbox?
Although Anbox doesn’t come with Google play services, you can still install an application manually using its APK file. First, you need to install ADB (Android Debug Bridge) on your host system to install the app.
You can run the command:
It installs all required tools, and now you can download the APK file of any application you want to install. You can get it from the website Apkmirror or Apkpure.
For checking the Android emulator devices running on your machine, you can use the following command to list all of them:
Next, run the below command to install the application, and it will automatically show in the Anbox.
Want more Android Emulators?
In the end, I would also like to mention other available top Android emulators for Linux that could turn out to be quite handy. To name a few, there is ARChon, AndyOS, and many more. But they’re still under development, and others have limited capabilities.
There are also some Android-x86-based Android OSes out there like Prime OS and Phoenix OS but, most of them are running far outdated versions of Android (Android 7.0 Nougat).
If you want an Android emulator for other platforms, you can read our article on the best android emulators for Windows PC and Mac.
- How can I run Android apps on Linux without an emulator?
A. You can run Android apps on Linux without an emulator using Anbox. It is like Wine, but instead of Apps and games, it runs Android applications on any GNU/Linux operating system. The host machine kernel is utilized to run Android apps instead of creating an emulated system.
2. Can Ubuntu touch run Android apps?
A. Yes, Android apps can now run on Ubuntu touch via Anbox. We have a dedicated article about the same so, make sure to check it out.
3. Is an Emulator different from a Virtual machine?
Virtual Machine, as the name suggests, provides a virtualized interface to the actual hardware. Whereas, Emulators imitate hardware without relying on the CPU resources, to run the code directly.
Источник