Our application has three dexes in apk which was built by gradle with multidex feature.
After the application was installed,
Were the main dex and the second dex loaded by the same class loader?
How to check if the second( classes2.dex ) and the third was loaded completed or not? Can I check it in code dynamically?
Or can you guys introduce any related document about the procedure of class( or dex ) loading in Android? I am not familiar with this.
Thank you.
I haven't dug into the ART code, but you can read what the Multidex support lib does for Dalvik here:
ClassLoader
. When your Application loads, the MultiDex
instrumentation:
ClassLoader
),ClassLoader
from your Application's context, and adds those new .zip files to the list that the ClassLoader
knows about reflectively.Not only are the separate dexes loaded by the same ClassLoader, they're loaded by the same ClassLoader that would be used without MultiDex.
The extra dexes should be setup automatically when your Application loads. It's not easy to check this in-code, but you can verify locally by checking the logs for your device.
There's some Android docs about the architecture of ART and Dalvik. But, there's nothing better than reading the source :)