Sound unit does not compile in Android mode

Hello everyone
Bonjour à tous

Depuis plus d’un an je rencontre des problèmes de génération d’APK avec diverses version de processing (la version 4.3.4 fonctionne normalement sous android)

Since more than a year, i enconted APK generations’s probleme on various version of processing (le 4.3.4 version is the last one which could compile on android)

Suit un petit programme simpliste qui permet d’exposer le problème qui réside dans l’unité Sound de processing.
Folowing a simple program who expose le main probleme located as I thought in Sound unit of processing system.

// The sample program.

import processing.sound.*;
SinOsc sin1;

float freqSto=440;

void setup()
{
sin1=new SinOsc(this);
sin1.play(freqSto,0.025);
}

int n=0;
void draw()
{
float freq=int(sin(n%100)*40+440);
if (freq!=freqSto)
{
sin1.play(freq, 0.025);
freqSto=freq;
}
n++;
}

/*
Bonjour,
Le programme fonctionne en mode java mais n’arrive pas à compiler en mode android.
(après avoir créé un jeu d’icônes pour pouvoir exporter le paquet !)

Ce petit programme est un “condensé” avec seulement quelques instructions et permet à
d’analyser le problème de l’unité de son en mode android.

Note : Je n’arrive pas à générer d’apk en utilisant la librairie sonore de processing depuis au moins un an.
Le problème était caché sur un gros programme et ce n’est que maintenant que je trouve le module coupable.

Résultat de la compilation sur processing 4.3.4 et mode android 4.6.1

Traduit avec DeepL.com (version gratuite)
Hi,

THe program Functions on java mode but unable to compile on android mode.
(after having created set of icons to be able to export package!)

This small program is a “digest” with only few instructions and permits
to analysis the problem of the sound unit on android mode.

Note : I am not able to generate apk using sound librarie from processing since at least a year.
The problem was hidden on a huge program and it is only now that I find the guilty module.

Result on compilation on processing 4.3.4 and android mode 4.6.1
//**********************************************************************************
Build folder: C:\Users\thais\AppData\Local\Temp\android14702403082400078256sketch
java.lang.NullPointerException: Cannot read the array length because “list” is null
at processing.app.Library.wrapFiles(Library.java:427)
at processing.app.Library.getApplicationExports(Library.java:437)
at processing.mode.android.AndroidBuild.copyImportedLibs(AndroidBuild.java:839)
at processing.mode.android.AndroidBuild.createAppModule(AndroidBuild.java:481)
at processing.mode.android.AndroidBuild.createProject(AndroidBuild.java:262)
at processing.mode.android.AndroidBuild.build(AndroidBuild.java:223)
at processing.mode.android.AndroidBuild.exportPackage(AndroidBuild.java:794)
at processing.mode.android.AndroidEditor$19.run(AndroidEditor.java:552)
//********************************************************************************

Si quelqu’un a une solution, je serai heureux de la connaître.
If anyone has one solution I’l be pleased to know it.

Salutations
Regards
Yves cordier

site : altituduino.com

/*

Your demo fails on my macOS m2 system with the same error message that you got. The following code which is simpler also demonstrates the problem in Android mode:

import processing.sound.*;

void setup() {
  Sound.list();
}

To see why it fails we need to follow the error message and go to this url:processing4/app/src/processing/app/Library.java at main · processing/processing4 · GitHub

Where we will find code like this:

line 428:
 protected File[] wrapFiles(String[] list) {
    File[] outgoing = new File[list.length];
    for (int i = 0; i < list.length; i++) {
      outgoing[i] = new File(libraryFolder, list[i]);
    }
    return outgoing;
  }

called by line 480:
  @SuppressWarnings("unused")
  public File[] getAndroidExports() {
    return wrapFiles(androidExportList);
  }

/** Android exports (single platform for now, may not exist). */
  String[] androidExportList;

    /*
    // not actually used in any libraries
    String androidExportStr = exportTable.get("android");
    if (androidExportStr != null) {
      androidExportList = PApplet.splitTokens(androidExportStr, ", ");
    } else {
      androidExportList = baseList;
    }
    */

In summary there is no ‘androidExportList’. The code that might have saved us was REMmed out. It is unable to to create an androidExportStr so in previous versions it would use the ‘baseList’ instead. The ‘baseList’ appears to be a ‘platform’ list for our operating system. Apparently now none of this is being done.

@sableraph Is this a known issue? If not I will file a report. Thanks.

(post deleted by author)