Alright, so the only way I found was to generate my own version of attach, with the additional service. There are 2 steps (in bold) which are unexpected:
A.Make a copy of https://github.com/gluonhq/attach
create a new module 'e.g.mynative' as a copy of an existing one. in the new module rename files and ids accordingly
in settings.gradle add lines:
include 'mynative'
...
project(':mynative...
- In ./util/src/main/native/android/c/util.c,
add the lines:
static jclass jMynativeServiceClass;
...
jclass substrateGetRinkainativeServiceClass() {
return GETREGISTERCLASS(jMynativeServiceClass,
"com/gluonhq/helloandroid/DalvikMynativeService");
}
- install
./gradlew publishToMavenLocal
B. Make a copy of https://github.com/gluonhq/client-maven-plugin
- In ./src/main/java/com/gluonhq/attach/AttachService.java add 'MYNATIVE' enum value
- install:
mvn clean package install
C. Consume service in your gluon mobile app
update version for client-maven-plugin plugin and attach dependency to the ones used in the steps above i.e. xxx-SNAPSHOT
in com.gluonhq:client-maven-plugin configuration add mynative to attachlist
use as other attach services, e.g
Services.get(MynativeService.class).ifPresent(service -> {
System.err.println("connected:"+service.connectedProperty().get());
});
Then to run on android:
mvn -o -P android clean client:build client:package client:install client:run
I have not tried it on IOS