Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Instant Run: legacy multi-dex on Dalvik runtime

When I ran my app, it said that

Cannot Instant Run: legacy multi-dex on Dalvik runtime

Does it means that I can't use Instant Run when I use multi-dex?

I'm using Android Studio beta4.

like image 578
tiny sunlight Avatar asked Sep 25 '22 09:09

tiny sunlight


2 Answers

In order to activate multiDex at old android versions you have to set multiDexEnabled to true, add dependency and extend your application class from MultiDexApplication or launch MultiDex.install(this) in your application class, which will cause legacy multiDex installation.

However since Intant Run can't work with legacy multiDex you have to use normal one. All you need is removing all that code above except of multiDexEnabled flag set to true. This method is only supported by devices with API 21 and above.

Feel free to correct me if something is wrong.

like image 62
Tieru Avatar answered Oct 11 '22 04:10

Tieru


As mentioned in the documentation Instant Run is disabled by Android Studio in case multidex is enabled for API level 20 or lower and app is deployed on API level 20 or lower.

Documentation link

like image 31
Kruti Parekh Avatar answered Oct 11 '22 05:10

Kruti Parekh