6 Replies Latest reply on Jul 24, 2017 5:11 PM by michaelarchbold

    Problems with multidexing in Air 25

    peter.nicolai.123 Level 1

      Hi,

       

      I left a comment on this ticket: Tracker , but it looks like it's maybe considered resolved now because nobody responded. Multidexing support is not working for us.

       

      What we are seeing is that any classes moved to classes2.dex are not available at runtime ( listed using dexdump classes2.dex | grep 'Class descriptor' ). So for example an ANE referencing classes that get put in the secondary dexfile will crash the app with Fatal Exception: java.lang.NoClassDefFoundError.

       

      Does anyone out there have an app that uses multidexing and doesn't have this issue?

        • 1. Re: Problems with multidexing in Air 25
          peter.nicolai.123 Level 1

          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.

          • 2. Re: Problems with multidexing in Air 25
            Rohit_Kumar Adobe Employee

            Hey,

             

            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.

             

            Thanks,

            Rohit

            Adobe AIR Team

            • 3. Re: Problems with multidexing in Air 25
              peter.nicolai.123 Level 1

              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.

              • 4. Re: Problems with multidexing in Air 25
                Radon_

                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")

                • 5. Re: Problems with multidexing in Air 25
                  peter.nicolai.123 Level 1

                  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.

                  • 6. Re: Problems with multidexing in Air 25
                    michaelarchbold Level 1

                    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>