class "Serial" does not exist

Hello!

I'm stuck with Processing. I had a simple project where I toggle RGB-buttons, I uploaded it to my Android phone, it worked.

I did some editing on it now I can't upload anymore. Realised it gave me an error message
class "Serial" does not exist

import processing.serial.*;

Serial myPort;

Serial is underlined with red.

I used a simple Sketch, can't upload this either.

Here the code for the sketch

import processing.serial.*;

Serial myPort;

void setup() 
{
 
  String portName = Serial.list()[2];
  myPort = new Serial(this, portName, 9600);
}




void draw() {
  if (keyPressed) {
    
    if (key=='r' || key=='R'){
    fill(0);                      //fill 0 = svart
    myPort.write(114);
    delay (1000);
    }
    
    if (key=='g' || key=='G'){
    fill(0);                      //fill 0 = svart
    myPort.write(103);
    delay (1000);
    }
    
    if (key=='b' || key=='B'){
    fill(0);                      //fill 0 = svart
    myPort.write(103);
    delay (1000);
    }

    
  } else {
    fill(255);                    //fill 255=white
    
}    
rect(25,25,50,50);        //25x25 square  in 50 by 50 palette
}

Here's the error message:

No library found for processing.serial
    [mkdir] Created dir: /var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/bin
     [echo] org.eclipse.jdt.core.JDTCompilerAdapter

-set-mode-check:

-set-debug-files:

-check-env:
Android SDK Tools Revision 25.2.3
Installed at /Users/AZMI/Documents/Arduino/android-sdk-macosx

-setup:
     [echo] Project Name: RGB_SimpleWrite
Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
Using latest Build Tools: 23.0.1
     [echo] Resolving Build Target for RGB_SimpleWrite...
Project Target:   Android 6.0
API level:        23
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/bin/res
    [mkdir] Created dir: /var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/bin/rsObj
    [mkdir] Created dir: /var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/bin/rsLibs
    [mkdir] Created dir: /var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/gen
    [mkdir] Created dir: /var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/bin/classes
    [mkdir] Created dir: /var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/bin/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for RGB_SimpleWrite...
Library dependencies:
No Libraries

------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
Merging AndroidManifest files into one.
Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 4 source files to /var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/bin/classes
----------
1. WARNING in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/MainActivity.java (at line 11)
	import android.support.v4.content.ContextCompat;
	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The import android.support.v4.content.ContextCompat is never used
----------
2. WARNING in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/MainActivity.java (at line 15)
	import android.Manifest;
	       ^^^^^^^^^^^^^^^^
The import android.Manifest is never used
----------
3. WARNING in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/MainActivity.java (at line 49)
	int check;
	    ^^^^^
The value of the local variable check is not used
----------
----------
4. ERROR in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/RGB_SimpleWrite.java (at line 8)
	import processing.serial.*; 
	       ^^^^^^^^^^^^^^^^^
The import processing.serial cannot be resolved
----------
5. ERROR in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/RGB_SimpleWrite.java (at line 24)
	Serial myPort;
	^^^^^^
Serial cannot be resolved to a type
----------
6. ERROR in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/RGB_SimpleWrite.java (at line 29)
	String portName = Serial.list()[2];
	                  ^^^^^^
Serial cannot be resolved
----------
7. ERROR in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/RGB_SimpleWrite.java (at line 30)
	myPort = new Serial(this, portName, 9600);
	^^^^^^
Serial cannot be resolved to a type
----------
8. ERROR in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/RGB_SimpleWrite.java (at line 30)
	myPort = new Serial(this, portName, 9600);
	             ^^^^^^
Serial cannot be resolved to a type
----------
9. ERROR in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/RGB_SimpleWrite.java (at line 41)
	myPort.write(114);
	^^^^^^
Serial cannot be resolved to a type
----------
10. ERROR in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/RGB_SimpleWrite.java (at line 47)
	myPort.write(103);
	^^^^^^
Serial cannot be resolved to a type
----------
11. ERROR in /private/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/src/processing/test/rgb_simplewrite/RGB_SimpleWrite.java (at line 53)
	myPort.write(103);
	^^^^^^
Serial cannot be resolved to a type
----------
11 problems (8 errors, 3 warnings)

BUILD FAILED
/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/build.xml:15: The following error occurred while executing this line:
/var/folders/d4/mm8qyq_x3s14727yg7qw4mhr0000gn/T/android704940619117704727sketch/build.xml:28: Compile failed; see the compiler error output for details.

Total time: 2 seconds

What happend? What am I missing?

What am I missing?

The fact that this isn't the Processing forum?

It appears as though you've trashed your Processing installation.

It says software, Processing..

"Interfacing w/ Software on the Computer -
Firmata, Processing, Max/MSP, PureData, VVVV, etc."

I figured since these programs work together it would be OK? So reinstalling then

I figured since these programs work together it would be OK?

If your questions involves Arduino and Processing communicating, yes. Other questions, less so.

Hopefully, reinstalling will fix whatever you broke. It's somewhat unfortunate that Processing doesn't have a compile and link without running option like Arduino has. Your code starts running for me, but immediately crashes, because I don't have an Arduino connected to the third serial port in the list (which, when I ran the program had 0 items in the list). But, at least it proves that there is nothing wrong with the code, but there is something wrong with your installation.

PaulS:
If your questions involves Arduino and Processing communicating, yes. Other questions, less so.

Hopefully, reinstalling will fix whatever you broke. It's somewhat unfortunate that Processing doesn't have a compile and link without running option like Arduino has. Your code starts running for me, but immediately crashes, because I don't have an Arduino connected to the third serial port in the list (which, when I ran the program had 0 items in the list). But, at least it proves that there is nothing wrong with the code, but there is something wrong with your installation.

Thanks for reply, last time when success I had my UNO and Android phone connected. That might be the problem, I'll try it gain.

thanks!