Problem when dexing extension

Hi,

I tried to wrap the HiveMQ MQTT client with an extension. When building the extrension I get the following error message:
dexExtension:
[java] Picked up _JAVA_OPTIONS: -Xmx1024m
[java]
[java] PARSE ERROR:
[java] InvokeDynamic not supported
[java] ...while preparsing cst 0005 at offset 0000001c
[java] ...while parsing com/hivemq/client/internal/mqtt/MqttAsyncClient.class
[java] 1 error; aborting

I inspected the build directory. All expected class files are present.

Using Google I got the hint that there might be a problem with Lambda functions. Indeed HiveMQ uses Lambdas.

Is it possible to solve or avoid the problem?

Kind regards
Ulrich

I found a partial solution.

First I updated dx.jar in ...\appinventor-sources\appinventor\lib\android\tools to version 1.16. When downloading the 'appinventor-sources' files version 1.13 was included.

Then I added
<arg value="--verbose"/>
to the dexing script in build.xml to get further informations. I got the message to use min-sdk-version >= 26. I added
<arg value="--min-sdk-version=26"/>
to the script. Now the extension compiles properly.

But when building the AI2 project the build process crashes:

App Inventor is unable to compile this project.
The compiler error output was
________Preparing application icon
________Creating animation xml
________Creating style xml
________Creating provider_path xml
________Creating network_security_config xml
________Generating adaptive icon file
________Generating round adaptive icon file
________Generating adaptive icon background file
________Generating manifest file
________Attaching native libraries
________Attaching Android Archive (AAR) libraries
________Attaching component assets
________Invoking AAPT
AAPT time: 1.522 seconds
________Compiling source files
(compiling appinventor/ai_bienonline/mqtt/Screen1.yail to appinventor.ai_bienonline.mqtt.Screen1)
(compiling /tmp/runtime7885492609027839261.scm to com.google.youngandroid.runtime)
Kawa compile time: 45.872 seconds
________Invoking DX
DX time: 21.979000 seconds
YAIL compiler - DX execution failed.

My extension class has these annotation:
@DesignerComponent(version = 1,
androidMinSdk = 26, ...

This should be taken into account when building the apk. And you should use the newest tool version.
For test you can download dx.jar from here: https://ullisroboterseite.de/_forDownload/dx.jar
The project file that includes the compiled extension: https://ullisroboterseite.de/_forDownload/mqtt.aia

Look in that class for what is causing the issue. Try process of elimination (which will be slow) and revert back to DX 13 to test if it worked or not. I had this problem once, but I don't quite remember what I did.

The MqttAsyncClient class is probably using lambda expressions which is a Java 8+ feature. Currently, App Inventor only supports Java 7 because the deprecated dx tool doesn't support Java 8+ and has been superceded by the modern D8 dex compiler. You must find a Java 7-compatible version of the same library.