How do I improve the speed of packaging APK?

The packaging of APK takes a long time, with runMultidex taking the longest time to execute. But I don't know how to optimize, I hope to get some suggestions

Have you exhausted your other debugging options, like using the Companion?

You can't optimize the run multidex step because the way it works requires loading all of the dex content into memory at once. If you switch to compiling and running with Java 11, App Inventor will use d8 and cache intermediate build files for each library to improve performance when multiple builds use the same library.