Using Serial with Processing for Android

I’m trying to use Bluetooth Classic from a Processing app (version 3.5.4) in the Android mode with a Serial library download from the internet “AndroidSerial”. Source code which fails is as follows:


void setup() {

void draw() {
  if (mousePressed) {
    if ((mouseX > 200) && (mouseX < 260) && (mouseY > 60) && (mouseY < 120)) {

The app crashes when the triangle is pressed. Error message follows:

FATAL EXCEPTION: Animation Thread
Process: processing.test.serialtest, PID: 18741
java.lang.IllegalArgumentException: This library works only on Android.
	at processing.test.serialtest.serialTest.draw(
	at processing.core.PApplet.handleDraw(
	at processing.core.PSurfaceNone.callDraw(
	at processing.core.PSurfaceNone$

I note that the library works only on Android, but the Android mode is selected and an Android sdk is installed on my system (macOS).

Have you tried this version of the lib?

@noel very helpful. Latest version of library no longer causes crash. However, now I get the following error message and I’m not sure how to fix it:

Processing-Android USB Serial ERROR

Check the following:
1) Make sure AndroidManifest.xm. contains <use-feature> tag for
2) USB Serial is connected to the device

I’m trying to get this demo to run on a Samsung tablet using an Arduino UNO connected to a Mac mini as the data source. The UNO has a classic Bluetooth shield which is sending test data (tested in another Processing java app and this is working). I have checked all the Bluetooth boxes under Android/Sketch Permissions but do not see “use-feature” in the manifest which is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="" android:versionCode="1" android:versionName="1.0" package="processing.test.serialtest">
    <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="28"/>
    <application android:icon="@mipmap/ic_launcher" android:label="serialTest">
        <activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED"/>

How would I add a tag for to the manifest in Processing?

I greatly appreciate your help.

@svan ===

<manifest ...>
    <uses-feature android:name="" />

And the port number is properly listed of course?

@svan === it seems to be null…

@noel and @akenaton

Adding the “uses-feature” to the manifest in the project folder didn’t solve the problem. I still get the same error message, therefore I am unable to get the demo to give me a serial port list. However, I have looked in the tablet’s settings and can see that I have previously paired the Bluetooth shield for use with another app. Just to see what would happen, I unpaired it and tried to re-pair it. Now it does not show the shield as being available for pairing and I am unsure why. For now it appears that recognition of the port is the problem and will need more trouble-shooting. I appreciate your help. Will provide follow-up if I ever get it working.

Have you closed all other programs that could be using your serial port, for example arduino serial monitor, hyperterminal, etc. ?

This can help?

@noel - USBDeview appears to be a Windows app and I’m doing this on a Mac. The serial ports on a Mac may be displayed in Terminal using the command “ls /dev/cu.*”. At any rate, I think I’m going down the wrong road; what I need is a list of paired Bluetooth devices and devices available for pairing on my Android tablet. Therefore, I don’t think “println(Serial.list(this))” will work for this purpose. Hopefully, there is another way to find Bluetooth devices using Processing Android; I need to read some more. Thanks.

The following code will find the Bluetooth devices paired with my Samsung tablet:

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import java.util.Set;

String[] devices = {};
 void findPairedBluetoothDevices() {
 BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
 if (adapter == null) {
    println("Device doesn't support Bluetooth.");
 } else {
   Set<BluetoothDevice> pairedDevices = adapter.getBondedDevices();
   if (pairedDevices.size() > 0) {
    // Get the name and address of each paired device.
     for (BluetoothDevice device : pairedDevices) {
       String deviceName = device.getName();
       String deviceHardwareAddress = device.getAddress(); // MAC address
       String deviceInfo = deviceName + "\n   " + deviceHardwareAddress;
       devices = append(devices, deviceInfo);

void setup() {

void draw() {
  color BLUE = color(64,124,188);
  for(int j = 0; j < devices.length; j++) {
  text(devices[j], 130, 100 + (180 * j), 500, 180);


Thanks for sharing…