I have a very strange issue i suspect related to multidexing (but not sure).
I have an app module and a library module. The library is executing some code on app start which, through an interface on the main application class, gets a class name defined in the library.
Now the strange part begins. The app is multidexed according to the following instructions - Configure Apps with Over 64K Methods - and I have 2 build types - debug and release. On release build im using proguard to obfuscate and shrink the code. On debug build im not.
When running the app on devices with android +21 everything works fine in both build types.
When running the app on devices with pre lollipop version everything works fine in release build type but in debug build type im getting NoClassDefFoundError
because of the class the application is trying to return to the library.
Following the suggestion in Declare classes required in the primary DEX file i've used the APK Analyzer in android studio to examine the distribution of classes between the dex files and saw 2 things:
Moreover, when im replacing the call from the library to the application (getClassName() in the diagram) with the actual class name everything is working fine in all build types!
As a last attempt to understand whats going on here i've compared the 2 apks, the original one with a one without the call to the application (replaced with actual class name), and the only difference i could see is the library code making the call. In terms of classes distribution between dex files there is absolutly no difference!
Does anyone understand whats the problem here ? Thanks.
eventually it was com/newrelic/agent/android/api/v2/TraceFieldInterface.class that i had to make sure is in the main dex file.
If someone is using newrelic you might want to pay attention to this.