# Problem with running a simple sketch on Android

**URL:** <https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732>\
**Category:** Processing for Android\
**Created:** [January 28, 2023, 6:54pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732 "2023-01-28T18:54:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [January 28, 2023, 6:54pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/1 "2023-01-28T18:54:58Z")

</div>

Hello,

For my [vinyl jukebox project](https://www.youtube.com/watch?v=ra-SkdNhQrw), which runs with processing, I would like to make an app to control the jukebox through wifi.

This is the first time I try to make an program for Android.  
I installed successfully Processing4 and the android mode on my PC with windows11. The sdk was also installed with the automatic method successfully, and so was the emulator.  
My phone (Xiaomi MI11) is in USB debug mode and I can see it is connected via the Android/devices menu.

When I launch the example sketch from the [android for processing tutorial](https://android.processing.org/tutorials/getting_started/index.html) , I have an encouraging last message in the console:

> BUILD SUCCESSFUL in 19s  
> 27 actionable tasks: 27 executed

But I also have these lines just before:

> Task :app:compileDebugJavaWithJavac  
> Annotation processing got disabled, since it requires a 1.6 compliant JVM  
> Task :app:dexBuilderDebug  
> Task :app:desugarDebugFileDependencies  
> Task :app:mergeExtDexDebug  
> Task :app:mergeDexDebug  
> Task :app:packageDebug  
> Task :app:createDebugApkListingFileRedirect  
> Task :app:assembleDebug  
> Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.  
> You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.  
> See [Command-Line Interface](https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings)

My phone then prompts if I want to install the app. After pressing the “Install” button on the phone, the program seems to be launched because the screen becomes white for a tenth of a second before showing the home menu again. I also get a lot of error messages lines, starting with:

> FATAL EXCEPTION: main  
> Process: processing.test.tutoandroid, PID: 24658  
> java.lang.VerifyError: Rejecting class processing.a2d.PSurfaceAndroid2D that attempts to sub-type erroneous class processing.core.PSurfaceNone (declaration of ‘processing.a2d.PSurfaceAndroid2D’ appears in /data/app/~~-bvU\_owdL5jMbZ3fu757Kw==/processing.test.tutoandroid-rBHYAJjU\_SUzumhNmU4O-Q==/base.apk)  
> at processing.a2d.PGraphicsAndroid2D.createSurface(PGraphicsAndroid2D.java:180)  
> at processing.core.PApplet.initSurface(PApplet.java:538)

and ending with:

> at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)  
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)  
> Caused by: java.lang.VerifyError: Verifier rejected class processing.core.PSurfaceNone: android.content.Context processing.core.PSurfaceNone.getContext() failed to verify: android.content.Context processing.core.PSurfaceNone.getContext(): [0x22] can’t resolve returned type ‘Reference: android.content.Context’ or ‘Unresolved Reference: android.support.wearable.watchface.WatchFaceService’ (declaration of ‘processing.core.PSurfaceNone’ appears in /data/app/~~-bvU\_owdL5jMbZ3fu757Kw==/processing.test.tutoandroid-rBHYAJjU\_SUzumhNmU4O-Q==/base.apk)  
> … 31 more

If I run the program with the emulator, the behaviour is exactly the same: the emulator is launched, the white screen for a fraction on second, and the same error messages on the console.

Here is the code from the tutorial that I am trying to run:

```auto
void setup() {
  fullScreen();
  noStroke();
  fill(0);
}

void draw() {
  background(204);
  if (mousePressed) {
    if (mouseX < width/2) {
      rect(0, 0, width/2, height); // Left
    } else {
      rect(width/2, 0, width/2, height); // Right
    }
  }
}

```

At this point, I am stuck!  
Does anybody know what the problem is and point me on how to solve it?

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 28, 2023, 7:27pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/2 "2023-01-28T19:27:00Z")

</div>

Hi

With processing 3.5.4 run fine

 ![Screenshot_2023-01-28-22-25-17-481](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/a/5a5629b5d3764e70a0f2177138d998e9385b64f9.jpeg)

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 28, 2023, 7:48pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/3 "2023-01-28T19:48:58Z")

</div>

Runs ok here on my Windows 11 system Processing version 4.1.1 with a Nexus 4 device. Sounds like you’re doing ok up until you go to install it on your device. The error message mentions ‘Unresolved Reference: android.support.wearable.watchface.WatchFaceService’. Are you trying to install it on a smartphone or tablet?

---

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [January 28, 2023, 11:13pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/4 "2023-01-28T23:13:41Z")

</div>

I try to run the code on a smartphone .  
My version of processing is 4.1.2. I will try tomorrow with the 4.1.1 version.

The 3.5.4 version is the one I normally use, but I was unable to correctly install the SDK with it: despite I accepted the licenses when I was prompted to after the automatic SDK installation, the build fails with error messages in the console, saying that some licences were not approved.  
I tried to approve these licences, with the “sdkmanager --licences” command from the tool/bin folder of the SDK, but with no success (error message saying that class files are not compatible with the Java Runtime Environment). That is why I then switched to Processing 4…

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 29, 2023, 12:57am UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/5 "2023-01-29T00:57:56Z")

</div>

> [@Glenton](#):
>
> My version of processing is 4.1.2. I will try tomorrow with the 4.1.1 version.

Should run with either version.

---

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [January 29, 2023, 4:11pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/6 "2023-01-29T16:11:12Z")

</div>

I tried today with the 4.1.1 version: the problem remains, with the exact same behaviour.

I also tried on an other PC with windows 10, with fresh installations of processing 3.5.4, and later of processing 4.1.2, and got exacly the same behaviour as on the other PC with windows11:

- With the 4.1.2, the app on the phone that uploads, runs and crashes immediately, with the very same error messages as I described earlier.

- With the 3.5.4, the same problem (with exactly same error messages) with the non approved licenses.

Tried also with another phone (LG G6), but no way to get it recognized as a device by processing, nor to find a USB driver for it…

Any Idea of what else I can do?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 29, 2023, 5:41pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/7 "2023-01-29T17:41:11Z")

</div>

Are we certain that USB debugging is turned on? It should recognize that LG G6. You have to tap the screen a number of times (at least seven as I recall) to activate it.

Does Android Studio recognize either of your Android devices?

---

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [January 29, 2023, 9:10pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/8 "2023-01-29T21:10:04Z")

</div>

Yes, it is in the usb debug mode.  
I activated the developer mode by tapping the serial some times, and then activated the usb debug mode.  
Maybe the problem with the g6 is rather a matter of usb driver, but I was unable to find the driver for that phone…

I tried the apde processing app, from he playstore. My sketch works with it, but is not very handy to write code directly from a phone…  
Moreover, just trying to import the [processing.net](http://processing.net):  
`import processing.net.*;`

Throws these error messages in the console, so I guess I won’t be able tu use this library that I will need for my project.

Initializing build sequence…  
Deleted old build folder  
No library found for [processing.net](http://processing.net)  
Injected log broadcaster  
Detected architecture arm64-v8a

## Packaging resources with AAPT… Compiling with ECJ…

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20230129c/sketch\_20230129c.java (at line 8)  
import [processing.net](http://processing.net).\*;  
^^^^^^^^^^^^^^  
The import [processing.net](http://processing.net) cannot be resolved

* * *

1. ERROR in /data/user/0/com.calsignlabs.apde/app\_build/src/processing/test/sketch\_20230129c/sketch\_20230129c.java (at line 23)  
Client myClient;  
^^^^^^  
Client cannot be resolved to a type

* * *

2 problems (2 errors)  
Compiling with ECJ failed

---

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [January 29, 2023, 9:18pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/9 "2023-01-29T21:18:37Z")

</div>

Svan, just to know if I should continue with processing or not for my project, can you tell me if the sketch still runs ok with your system with "import [processing.net](http://processing.net).\*; " at the beginning of the sketch?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 29, 2023, 9:33pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/10 "2023-01-29T21:33:11Z")

</div>

It fails with “import [processing.net](http://processing.net)” You shouldn’t have to be doing all these gymnastics.

![Screen Shot 2023-01-29 at 3.31.35 PM](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/c/c/cc97c799ba1460096725cd9692defe7e14e4e893.png)

Have you tried Android Studio to see if it recognizes your devices?

> Detected architecture arm64-v8a

Who has the arm64?

---

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [January 30, 2023, 7:40am UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/11 "2023-01-30T07:40:49Z")

</div>

Ok, thank you for this information 😅

Tried with android studio. The lg g6 is still not recognised but everything is ok with the Xiaomi.  
Moreover, I can successfully download apps on the phone with AS.

So I will stop trying with processing for now, looks it is not appropriate for what I want to do.  
It’s a pity, I love processing and I never used AS before. Hope it will not be too hard to learn 😅

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 30, 2023, 8:29am UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/12 "2023-01-30T08:29:56Z")

</div>

`It’s a pity, I love processing and I never used AS before.`

There is a way to use Processing code in Android Studio; the reference is here: [https://android.processing.org/tutorials/android\_studio/index.html](https://android.processing.org/tutorials/android_studio/index.html). It involves importing fundamental Processing library files into AS.

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [January 30, 2023, 11:14am UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/13 "2023-01-30T11:14:30Z")

</div>

A lot of libraries don’t seem to work with Processing for Android, even some that are supposed to be compatible, and there doesn’t seem to be a lot of interest on the part of the developers (assuming the library hasn’t already been abandoned) to get them to work. So IMHO, as long as you don’t need to use any add-on libraries, P4A is great. Otherwise, go with Android Studio. I’ve just started to learn AS myself.

There may also be issues depending on which version of Android you’re on. I’m not familiar with the devices you mentioned, but that might be something to look into.

---

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [January 30, 2023, 6:05pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/14 "2023-01-30T18:05:20Z")

</div>

First step done!  
Thanks to the tutorial you mentionned ,svan, I was able to run a processing sketch on my phone using Android Studio! It even works very well with the emulator!

But the problem with the `import processing.net.*;` still remains. I guess that as said David, this library won’t work with processing for android…

I have seen that some examples exist in Android Studio, to make client/server applications. I am going to dig through that…  
I am really new to android Studio, so I don’t know if it will be possible but maybe a “mix” with processing and these client/server example is possible?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 30, 2023, 7:04pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/15 "2023-01-30T19:04:50Z")

</div>

Not sure that it would work, but could also try directly adding the library to Processing’s library folder by drag and dropping it onto the sketch (I have not tried it). Alternatively might be able to add it to AS.

---

<div class="post-metadata">

**Author:** ![Glenton](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Glenton](https://discourse.processing.org/u/Glenton)\
**Post date:** [January 31, 2023, 9:52am UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/16 "2023-01-31T09:52:09Z")

</div>

I am not sure to know AS enough to do that but I can try.  
where can I fin this library in processing?

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 31, 2023, 4:20pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/17 "2023-01-31T16:20:07Z")

</div>

In your Documents/Processing folder is a folder called ‘libraries’. The library that you want to use should be in that folder. It might be better if you let Processing place it in there as opposed to copy/pasting it in there yourself, but you can try both ways. Supposedly dragging and dropping the library that you want to add onto your sketch will cause it to automatically be added to the libraries folder. I’ve never done it myself but have heard other forum members describe this technique; it might be worth a try. As far as AS you would probably use a technique similar to what you used to add the Processing libraries.

I’m not sure what the [processing.net](http://processing.net).\* library does or who owns it. Is it associated with [Processing.org](http://Processing.org) or is it a proprietary library used for billing? I was unable to find it on the internet.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 31, 2023, 5:16pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/18 "2023-01-31T17:16:49Z")

</div>

> [@svan](#):
>
> I’m not sure what the [processing.net](http://processing.net).\* library does or who

Hi

> <https://github.com/processing/processing/tree/master/java/libraries/net/src/processing/net>
>
> //github.com/processing/processing/tree/master/java/libraries/net/src/processing/net

---

<div class="post-metadata">

**Author:** ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)\
**Post date:** [January 31, 2023, 5:29pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/19 "2023-01-31T17:29:18Z")

</div>

Thank you. We ought to be able to add this to the project.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [January 31, 2023, 8:02pm UTC](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732/20 "2023-01-31T20:02:17Z")

</div>

> [@Glenton](#):
>
> But the problem with the `import processing.net.*;` still remains. I guess that as said David, this library won’t work with processing for android…

Hi

Read this

> [@Android mode import processing.net fails build](https://discourse.processing.org/t/android-mode-import-processing-net-fails-build/28473):
>
> Is there an alternative library to replace import [processing.net](http://processing.net).\* that is not available in Android mode apparently? In Java mode I use Client ([processing.net](http://processing.net)) to telnet into other devices on my local network. thanks,

[Next page](https://discourse.processing.org/t/problem-with-running-a-simple-sketch-on-android/40732.md?page=2)
