Why is it recommended to use the MultiDex.install () method in the attachBaseContext (Context) file?

I am studying multiDex on the Android platform. Here is https://developer.android.com/tools/building/multidex.html#mdex-gradle . When I use the multiDex support library, the apk output will contain files with several dex, such as class.dex, class1.dex, class2.dex. Then I write a class named myApplication , inherited from Application , and override the api attachBaseContext . In the method, I call MultiDex.install() in the same way as recommended.

My question is what happens if I used MultiDex.install() in onCreate ?

I know that attachBaseContext is called before onCreate , so attachBaseContext is called better. Howerver, actually I want to know why it is only recommended here? Is this a situation where a ClassNotFoundException is thrown when I call it in onCreate?

+7
java android
source share

No one has answered this question yet.

See related questions:

23498
Why is processing a sorted array faster than processing an unsorted array?
6549
Why is the subtraction of these two times (in 1927) giving a strange result?
3486
Why do Java + =, - =, * =, / = assignment operators do not require casting?
3295
Why is the Android emulator so slow? How can we speed up Android emulator development?
3156
Why is char [] preferred over String for passwords?
2727
What is serialVersionUID and why should I use it?
2643
Why is print "B" much slower than print "#"?
2108
How can I name one constructor from another in Java?
1975
What is reflection and why is it useful?
1844
What is "Context" on Android?

All Articles