Introduction into Android Development
Table of Contents
Prev Tutorial: Introduction to OpenCV Development with Clojure
Prev Tutorial: Introduction to OpenCV Development with Clojure
| Original author | Rostislav Vasilikhin |
| Compatibility | OpenCV >= 4.0 |
This guide was designed to help you in learning Android development basics and setting up your working environment quickly. It was tested with Ubuntu 22.04 and Windows 10.
If you encounter any error after thoroughly following these steps, feel free to contact us via OpenCV Forum. We'll do our best to help you out.
Android is a Linux-based, open source mobile operating system developed by Open Handset Alliance led by Google. See the Android home site for general details.
Development for Android significantly differs from development for other platforms. So before starting programming for Android we recommend you make sure that you are familiar with the following key topics:
In this tutorial we're gonna use an official Android Studio IDE and a set of other freely available tools.
Here's how to get a ready to work environment:
Install-Linux-tar.txt: open android-studio/bin folder in terminal and run ./studio.shInstall fresh Android SDK and NDK:
sudo apt install git cmake ninja-build openjdk-17-jdk openjdk-17-jre<YOUR_OPENCV_BUILD_FOLDER>/OpenCV-android-sdk/samples in Android Studio.
15-puzzle) and run it.Usually the recipe above works as expected, but in some cases there are additional actions that must be performed. In this section we'll cover some cases.
If you have Windows 10 or higher then you don't have to do additional actions to connect a phone and run samples on it. However, earlier Windows versions require a longer procedure:
<Android SDK folder>/extras/google/usb_driver/ folder.
USB\VID_XXXX&PID_XXXX&MI_XX.
<Android SDK folder>/extras/google/usb_driver/android_winusb.inf. Select either Google.NTx86 or Google.NTamd64 section depending on your host system architecture.
android_winusb.inf file and try to install the USB driver again.
While the latest Ubuntu versions work well with connected Android devices, there can be issues on older versions. However, most of them can be fixed easily. You have to create a new **/etc/udev/rules.d/51-android.rules** configuration file that contains information about your Android device. You may find some Vendor ID's here or execute lsusb command to view VendorID of plugged Android device. Here is an example of such file for LG device:
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"Then restart your adb server (even better to restart the system), plug in your Android device and execute adb devices command. You will see the list of attached devices:
savuor@rostislav-laptop:~/Android/Sdk/platform-tools$ ./adb devices
List of devices attached
R58MB40Q3VP device
savuor@rostislav-laptop:~/Android/Sdk/platform-tools$No actions are required, just connect your device via USB and run adb devices to check connection.
Now, when you have your instance of OpenCV4Adroid SDK set up and configured, you may want to proceed to using OpenCV in your own application. You can learn how to do that in a separate Android Development with OpenCV tutorial.