[LINUX] I want to develop an Android application on Android (debugging)

Introduction

This is a continuation of I want to develop Android apps on Android. It describes from installing adb, a tool for debugging, to actually starting the debugger using Android Studio.

important point

You need one PC. It cannot be implemented on Android alone. This time, I will introduce the procedure using Windows.

Android needs to be connected to a router etc. via Wifi.

The screen display of Ubuntu is described on the assumption that XSDL is used.

Download SDK Platform Tools

Open the following site on Windows, download the SDK Platform Tools, and unzip it.

https://developer.android.com/studio/releases/platform-tools.html

After unzipping, you should find the adb.exe file in the platform-tools folder. You will use adb.exe later.

USB driver installation

Install the USB driver on Windows. Later I will connect my Windows and Android device with a USB cable, Use the USB driver to recognize your Android device from Windows. I can't write the procedure because the driver is different for each company that develops Android devices. It will be thrown round, but please install it referring to the following site.

https://developer.android.com/studio/run/oem-usb

Turn on USB debugging enablement

Turn on the developer option on your Android device, then turn on USB debugging. When enabled, it runs in debug mode and can be stopped in the middle of the program. Since the procedure is different for each Android device, please refer to the following site as it can not be written.

https://developer.android.com/studio/debug/dev-options

Install adb on Ubuntu

Start UserLAnd or Termux Ubuntu on an Android device and execute the following command from LXTerminal etc. to install adb.


#Install adb on Ubuntu (Termux does not require sudo; UserLAnd requires sudo)
sudo apt install -y adb

#Copy adb and make it available from Android Studio
cp /usr/bin/adb ~/Android/Sdk/platform-tools/

Allow Android devices to be debugged via Wifi

Connect Windows and Android with a USB cable. A dialog will appear, so press the OK button.

Right-click on the Windows mark and select "Run". Type cmd in the name field and press Enter to bring up the command prompt.

Use the cd command to go to the platform-tools directory where the adb command is located, and use adb to connect to your Android device via Wifi as shown below.


# D:\platform-tools_r29.0.6-windows\To platform-If you have tools. Please read as appropriate according to the decompression destination you specified.
cd D:\platform-tools_r29.0.6-windows\platform-tools

#Set up your Android device to connect via Wifi
adb tcpip 5555

Execute adb and when "restarting in TCP mode port: 5555" is displayed, disconnect the USB cable. The settings you make here will take effect until you restart Android.

Debugger execution

Launch the Ubuntu desktop environment, then launch Android Studio. (If you have already started Android Studio, please close it and then restart it.) If the Android device name appears in the combo box at the bottom of the menu, it is successful. It is ready for debugging.

Let's actually try the debugger.

First, after creating a suitable project, open MainActivity.java. You should see the onCreate method. Click on the right side of the line number on the left side of the first line in the method, the line that says super.onCreate ~. Is it circled? Pauses the running program at this circle.

Next, there are four buttons on the right side of the Android device name under the menu that are shaped like insects. Press the bug button. After a while, the app will launch and you will see Waiting For Debugger. Do not press Force Close at this time.

Open the Android notification area and click XServer XSDL is running. (Be careful not to touch Stop on the right side) After returning to Android Studio and waiting for a while, Waiting For Debugger will automatically disappear and start debugging. It should have stopped at the circled line earlier.

Now you can debug. The fact that you don't need an emulator may be an advantage.

Recommended Posts

I want to develop an Android application on Android (debugging)
I want to develop Android apps on Android
I want to use Linux on mac
I want to make an automation program!
I want to operate DB using Django's ORM from an external application
I want to display an image on Jupyter Notebook using OpenCV (mac)
I want to be an OREMO with setParam!
I want to do pyenv + pipenv on Windows
I want to log file I / O on Linux
I want to convert an image to WebP with lollipop
I want to find a popular package on PyPi
I want to AWS Lambda with Python on Mac!
I want to use OpenJDK 11 on Ubuntu Linux 18.04 LTS / 18.10
I made an Android application that displays Google Map
I tried to make an OCR application with PySimpleGUI
I want to restart CentOS 8 on time every day.
I want to do Wake On LAN fully automatically
I want to solve Sudoku (Sudoku)
I want to disable interrupts on Raspberry Pi (≒ DI / EI)
I want to announce my graduation thesis on IPython Notebook
I want to convert an ISO-8601 character string to Japan time
Use Xming to launch an Ubuntu GUI application on Windows.
I want to use the Ubuntu desktop environment on Android for the time being (Termux version)
I want to use Ubuntu's desktop environment on Android for the time being (UserLAnd version)
What I did to output application logs on GAE Flexible Environment.
I get an ImportError on appengine_config.py
I want to understand systemd roughly
I just wrote a script to build Android on another machine
I want to know if you install Python on Mac ・ Iroha
I want to use an external library with IBM Cloud Functions
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
I want to use Ubuntu's desktop environment on Android for the time being (Termux version-Japanese input in desktop environment)
I want to pass an argument to a python function and execute it from PHP on a web server
I want to tweet on Twitter with Python, but I'm addicted to it
"CSI" that I want to teach beginners in interactive console application production
Tips for manipulating numpy.ndarray from c ++ -I want to use an iterator-
I want to use the Django Debug Toolbar in my Ajax application
I want to color a part of an Excel string in Python
I want to leave an arbitrary command in the command history of Shell
I want to create an Ubuntu chrome User Profile with Colab only
I want to format and check Python code to my liking on VS Code
I want to make a web application using React and Python flask
I want to pin Spyder to the taskbar
I want to output to the console coolly
I created an SFTP-only user on Linux.
I want to print in a comprehension
I want to scrape them all together.
I want to handle the rhyme part1
I want to know how LINUX works!
I want to handle the rhyme part3
I want to use jar from python
I want to build a Python environment
I want to pip install with PythonAnywhere
I want to analyze logs with Python
I was addicted to Flask on dotCloud
I want to play with aws with python
I want to use IPython Qt Console
I want to display the progress bar