# Installed Apps Crashes using Processing 4.2 Android Mode

**URL:** <https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111>\
**Category:** Processing for Android\
**Created:** [May 30, 2023, 2:20pm UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111 "2023-05-30T14:20:32Z")\
**Posts on this page:** 16\
**Page:** 2

<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:** [June 3, 2023, 3:20pm UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/22 "2023-06-03T15:20:53Z")

</div>

> Though those codes worked in processing 3 before

The syntax may have changed; I doubt that it has anything to do with Processing.

**Addendum:**  
It runs without error on my Mac once all the errors are either fixed or Remmed out.

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 6, 2023, 2:26pm UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/23 "2023-06-06T14:26:12Z")

</div>

I already gave up on the Android Dev using processing 4 using Bluetooth applications, processing android is unstable for me, it does not work on old codes most of the time.

Though I thank you for your responses, much appreciated.

---

<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:** [June 6, 2023, 5:34pm UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/24 "2023-06-06T17:34:29Z")

</div>

> processing android is unstable for me, it does not work on old codes most of the time.

I am fairly confident that the problem is in the code and not in Processing Android mode, not withstanding the fact that the last release had some issues. The code that you posted appeared to be old boilerplate code that needed to be updated. It was hard-coded to connect to a certain device so there is no way anyone else could fully test it on their system. In general Android bluetooth programming is not easy, but for me Android mode in Processing is much easier than the alternatives.

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 6, 2023, 6:32pm UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/25 "2023-06-06T18:32:03Z")

</div>

That is why I am trying to convert it to a PC based system, not using android mode.

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 7, 2023, 6:37pm UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/26 "2023-06-07T18:37:55Z")

</div>

Don’t get me wrong, I also like Android, which is why I still use it, but when it comes to Bluetooth connectivity, there are always deprecated codes, and when processing updates while codes in Bluetooth Android become deprecated, codes always keep on being updated. Unfortunately, Java mode can’t be used in mobile phones, though if it is possible to use, please let me know.

Thank you

---

<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:** [June 7, 2023, 9:46pm UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/27 "2023-06-07T21:46:22Z")

</div>

It’s the Android code that becomes ‘deprecated’ first. The folks who are kind enough to write the editor are just trying to keep up (it’s no different in any other language). That project that you had should be fixable by updating the source code. For example, functions that used to return a byte now return a byte array. I made those changes and your code ran without error, except for the fact that it really didn’t do anything on my system because you had it hard-coded to some server or device somewhere. Furthermore, it’s a mystery what is on the other end; there was no Arduino code posted. If you want to try and fix it then we’re willing to help, but you are going to have to give us more information than you have.

Java mode can’t be used for Android mobile devices as far as I know. Android has its own way of doing things. No big deal, you just have to learn the language. It is possible to use some java code (but not all) on an Android device.

If you really want to learn Android bluetooth communication then I would suggest starting with something really simple then gradually increasing the complexity as you learn.

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 8, 2023, 4:35am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/28 "2023-06-08T04:35:51Z")

</div>

The code I sent here has all the information, the only difference is the App should run when connected to Bluetooth… The problem with Android mode is there is no library for it in processing, unlike in Java mode or pc based. For example in Java mode, pc based, we can use import processing.serial.\*. In Android mode, there is no such thing. So my only issue with Android mode in processing is when the need of Bluetooth communication is needed.

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 8, 2023, 4:42am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/29 "2023-06-08T04:42:35Z")

</div>

By the way, the error in using the return byte did not appear on my end using Android mode.

---

<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:** [June 8, 2023, 5:14am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/30 "2023-06-08T05:14:10Z")

</div>

> the only difference is the App should run when connected to Bluetooth

Bluetooth is for serial communication; it connects an Android device to some other device wirelessly. What does the code that you posted connect to? Commonly it connects to an Arduino.

There is boilerplate code for Android bluetooth communication and that’s usually what you use. There are a series of steps that will find a device to connect to and then create a socket and connect to it.

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 8, 2023, 5:28am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/31 "2023-06-08T05:28:38Z")

</div>

It connects to an Arduino device via HC-06 Bluetooth.

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 8, 2023, 5:30am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/32 "2023-06-08T05:30:45Z")

</div>

Is P5.js feasible in connecting Arduino Uno via HC-06, have not tried it though. If this would be possible connecting both pc and mobile phone via Internet.

---

<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:** [June 8, 2023, 5:44am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/33 "2023-06-08T05:44:47Z")

</div>

> It connects to an Arduino device via HC-06 Bluetooth.

You did not post the Arduino code (which is necessary for testing).

---

<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:** [June 8, 2023, 5:47am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/34 "2023-06-08T05:47:55Z")

</div>

> Is P5.js feasible in connecting Arduino Uno via HC-06

There is a utility app called P5SerialControl which will facilitate serial connections. I’ve used it once or twice but otherwise don’t have much experience with this. Source code is here: [https://github.com/p5-serial/p5.serialport](https://github.com/p5-serial/p5.serialport)

---

<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:** [June 8, 2023, 6:07am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/35 "2023-06-08T06:07:56Z")

</div>

> the error in using the return byte did not appear on my end using Android mode.

I just tried running your bluetooth code again from the original post (the first time I scraped it out of the e-mail post, this time it was formatted correctly) and this time it ran without errors. Below is what I see on an Android tablet; the app does nothing. There is no interface.

 ![bt](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/2/b2ae7c72ac793d09ebe847b16cbac182d7c46e72.png)

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 8, 2023, 6:13am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/36 "2023-06-08T06:13:06Z")

</div>

Oh, I forgot…

This is the Arduino Code:

```auto
#include <SoftwareSerial.h>

#define RxPin 4
#define TxPin 2
#define DEBUG_ENABLED 1

SoftwareSerial BTSerial(RxPin, TxPin);

char val;

void setup()
 {

   pinMode(RxPin, INPUT);
   pinMode(TxPin, OUTPUT);
   
   BTSerial.begin(9600);
 }
 
void loop() {
  if (BTSerial.available());
    {
    val = BTSerial.read()
    }
    delay(20);
}

```

It connects to HC-06, it is only used to test connectivity

---

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [June 8, 2023, 6:14am UTC](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111/37 "2023-06-08T06:14:24Z")

</div>

Ok thank you, I will try this too.

[Previous page](https://discourse.processing.org/t/installed-apps-crashes-using-processing-4-2-android-mode/42111.md?page=1)
