# Use Serial over USB

**URL:** https://discourse.processing.org/t/use-serial-over-usb/8296
**Category:** Processing for Android
**Created:** [February 11, 2019, 9:22pm UTC](https://discourse.processing.org/t/use-serial-over-usb/8296 "2019-02-11T21:22:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Waldhuhn](https://avatars.discourse-cdn.com/v4/letter/w/9e8a1a/32.png) [@Waldhuhn](https://discourse.processing.org/u/Waldhuhn)
#### Post date: [February 11, 2019, 9:22pm UTC](https://discourse.processing.org/t/use-serial-over-usb/8296/1 "2019-02-11T21:22:52Z")

</div>

Hi,

I want to use the USB(OTG) of my mobile to connect an external sensor.  
I downloaded the inventit serial lib and imported it.

Following error:

Build folder: /tmp/android3025816262146606534sketch  
:app:preBuild UP-TO-DATE  
:app:preDebugBuild  
:app:compileDebugAidl  
:app:compileDebugRenderscript  
:app:checkDebugManifest  
:app:generateDebugBuildConfig  
:app:prepareLintJar  
:app:generateDebugResValues  
:app:generateDebugResources  
:app:mergeDebugResources  
:app:createDebugCompatibleScreenManifests  
:app:processDebugManifest  
:app:splitsDiscoveryTaskDebug  
:app:processDebugResources/home/chef/.gradle/caches/transforms-1/files-1.1/design-26.0.2.aar/2ef8d6e150681bb2d40be44cc2bffdb9/res/values/values.xml:245:5-97: AAPT: error: resource attr/colorPrimary (aka processing.test.serial\_test\_02:attr/colorPrimary) not found.

/home/chef/.gradle/caches/transforms-1/files-1.1/design-26.0.2.aar/2ef8d6e150681bb2d40be44cc2bffdb9/res/values/values.xml:256:5-258:13: AAPT: error: resource attr/colorAccent (aka processing.test.serial\_test\_02:attr/colorAccent) not found.

/home/chef/.gradle/caches/transforms-1/files-1.1/design-26.0.2.aar/2ef8d6e150681bb2d40be44cc2bffdb9/res/values/values.xml:256:5-258:13: AAPT: error: resource attr/selectableItemBackground (aka processing.test.serial\_test\_02:attr/selectableItemBackground) not found.

Source:

import io.inventit.processing.android.serial.\*;

Serial myPort; // The serial port  
PFont myFont; // The display font  
String inString; // Input string from serial port  
int lf = 10; // ASCII linefeed

void setup() {  
size(400,200);  
// You’ll need to make this font with the Create Font Tool  
myFont = loadFont(“FreeMonoBold-48.vlw”);  
textFont(myFont, 18);  
// List all the available serial ports:  
printArray(Serial.list(this));  
// I know that the first port in the serial list  
myPort = new Serial(this, Serial.list(this)[0], 9600);  
myPort.bufferUntil(lf);

// Create a new file in Sketch directory  
output = createWriter(“serialdata.txt”);

}

void draw() {  
background(0);  
text("received: " + inString, 10,50);  
}

void serialEvent(Serial p) {  
inString = p.readString();  
output.println(inString);  
output.flush(); // Writes the remaining data to the file  
output.close(); // Finishes the file

}

Has somebody an idea?

Android: 4.4.2  
Ubuntu Kernel 4.15.0  
Processing 3.4

---

<div class="post-metadata">

### Author: ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)
#### Post date: [February 12, 2019, 10:32am UTC](https://discourse.processing.org/t/use-serial-over-usb/8296/2 "2019-02-12T10:32:36Z")

</div>

@Waldhuhn===  
at first look (but perhaps i am wrong!) this error does not involve your lib but the material design dependency from appCompat, which is supposed to run with your os version. When you compile some sketch without the lib are you getting some error?

---

<div class="post-metadata">

### Author: ![Waldhuhn](https://avatars.discourse-cdn.com/v4/letter/w/9e8a1a/32.png) [@Waldhuhn](https://discourse.processing.org/u/Waldhuhn)
#### Post date: [February 12, 2019, 9:17pm UTC](https://discourse.processing.org/t/use-serial-over-usb/8296/3 "2019-02-12T21:17:24Z")

</div>

Hi akenaton,

you’re right, it seems like a problem with Linux.  
I tried a android example “AdditiveWaves” and I get also an built error.  
I did the same on Win7 and it works.  
Reason? I have no idea.
