Just an update:
I tried putting just the class referenced by the NoClassDefFoundError in the keepfile (no others) and it actually caused the build to only use one dexfile, which also took care of the crash. I don't know why or how this happened but I guess it will be fine for now.
I'm thinking you might want to tell people that starting with this version of AIR, rather than failing the build, if their app has >65k functions in it, AIR will quietly switch to multidex mode which means they'll have to add lines to that keep file to avoid crashing. You should probably also provide a way to disable multidex (or document it if one already exists). Since it seems like all classes in ANEs need to be in the main dexfile, why not have the packager handle that automatically? It's awkward that we have to modify a file in the AIR SDK directory to do this, and it's time-consuming to figure out which classes need to be included in it.
Is it possible for you to share the project? We will be able to give you better suggestions after looking at the project.
We can't add all the ANEs to the main dex file in the package, as it might again cause the main dex file to cross the limit of 64k.
Adobe AIR Team
My post detailed the way I was able to solve our problem for the time being, and suggested that you guys provide more complete documentation of how to use this feature - for example, how to add classes from an ANE to the secondary dexfile and still have it work properly - as well as a way to disable it in the build if desired. Not quite sure how sending you our source code is related to those things, and in any case I can't, any more than you can send me the source code to the closed-source portions of AIR/Flash.
Could it be that you are testing on a device with an Android version < 5.0 ?
We've made the experience, that it works fine on Android 5.0+, but not on older version.
It may have to do with with the fact that Android < 5.0 requires a support library to be able to run multidex builds (see https://developer.android.com/studio/build/multidex.html
(especially the paragraph "Multidex support prior to Android 5.0")
Hm no this was with 5.1, although if this could break in other ways on android 4.x then it shouldn't be listed as supported in the system requirements. Like I said, adding the one class mentioned in the class-not-found error to the keepfile fixed it. But I don't know why, and I don't know what was wrong with that class being in the secondary file in the first place. It was totally trial and error. I'd rather have documentation about how to correctly use this feature, and the ability to disable it.
I think we finally have a solution to this multidex issue on Android < 5. It's actually turned out to be a lot simpler than we had first approached it and would appreciate if everyone could double check our findings.
Firstly make sure you are using AIR 25+ (recommend using 26).
Then change the manifest additions for the application tag to match the following and use the MultiDexApplication:
<manifest android:installLocation="auto"> <!-- PERMISSIONS --> <application android:name="android.support.multidex.MultiDexApplication"> <!-- ACTIVITIES / RECEIVERS / SERVICES --> </application> </manifest>
A bit of a delayed reply...
I tried adding android:name="android.support.multidex.MultiDexApplication" to the application tag. This does indeed fix the problems we were having with Multidex builds on Android < 5. (I'm using AIR SDK 29 beta at the moment)
That is a great help! Thanks a lot!