Why does this code not work?

i tried this code in android studio and it says “cannot resolve” next to a lot of lines.

package com.example.test;

public class Sketch extends PApplet {
    // Sketch.java
package tutorials.androidstudio.fragmentsv4;

import processing.core.PApplet;

    public class Sketch extends PApplet {
        public void settings() {
            size(600, 600);
        }

        public void setup() {
        }

        public void draw() {
            if (mousePressed) {
                ellipse(mouseX, mouseY, 50, 50);
            }
        }
    }
}

Processing.GitHub.io/processing-javadocs/core/processing/core/PApplet.html#runSketch-java.lang.String:A-processing.core.PApplet-

Have you imported processing core into android studio

i think i did

The guide says it needs to be in the lib folder.

Did you also add it to the dependencies as per the tutorials instructions?

i think i did. how can I check?

Not sure, I’ve only recently created my first empty activity in android studio. I haven’t even added the sketch files.

well I think i did, I read the steps twice

Just tested, it should work, I have no red lines.

I have no idea what i did wrong, i tried it like three times.

could you show me what you did?

ok so I do have some errors, not all the import statements work

wait do you have to make the sketch in processing first?

could you explain what you did?

I followed the steps on the link, however 2 of my imports do not work.

import androidx.appcompat.app.AppCompatActivity;
import processing.android.CompatUtils;

so I figured out I was using the wrong jar. I used the one that i used to build libraries and its slightly different. However now I get an error for onRequestPermission

and an error for the fragment activity

fragment.setView(frame, this);

despite both of these error the procject builds fine

For whatever it’s worth, I have it running on a Mac also:

1 Like