Serial communication between android and microcontroller


I am using Processing 3.5.2 on windows 7. Making an application for android which deals with serial communication. (wired and not Bluetooth).

Now, If I use the program in java mode with corresponding default serial library, it works just fine. But problem occurred when I shifted to android mode. I used the library from this site:
Even after following the instructions very carefully. It failed.
Now, the issue was that the connection between android and the computer (for launching the application on the device) and the connection between android and the micro controller (for data transfer) uses a common port i.e. the mini-usb port. So, the program was written in such a way that the serial connection will only be done after a click on the screen.
With this Processing tells me “built successful” and it launches the application on the device when i click ‘run on device’.
After this when I close the app and reopen it , connect the micro controller connection and click the button to connect serial, it gives me this error:

java.lang.IllegalArgumentException: This library works only on Android.
at processing.test.android_mode_network_analyzer.Android_mode_Network_analyzer.mousePressed(
at processing.core.PApplet.mousePressed(
at processing.core.PApplet.handleMouseEvent(
at processing.core.PApplet.dequeueEvents(
at processing.core.PApplet.handleDraw(
at processing.core.PSurfaceNone.callDraw(
at processing.core.PSurfaceNone$

Even after I do things as mentioned on that aforementioned site, it doesn’t work.

Any suggestions? I am suspecting the library because everything works fine in java mode.