Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "package android.support.multidex does not exist" after upgrading to Android Studio 2.3

I updated from Android Studio 2.2.3 to Android Studio 2.3 yesterday, and I ran into the following two problems:

  • Upon updating, Gradle 3.2 was installed by default, but syncing my project would not work and I kept getting an error saying "Gradle 3.3 is required". Using the default Gradle wrapper doesn't work. The only way to fix this was to download Gradle 3.3 manually and point to the directory in build settings.

  • On running my project, I kept getting a string of errors involving my BaseApplication class which extends MultiDexApplication. The error goes something like this:

    Error:(19, 62) error: package android.support.multidex does not exist

I am unable to resolve this error. I have buildToolsVersion '25.0.2', and my project compiled and ran properly before upgrading to Android Studio 2.3. Can anyone help me with this problem?

like image 600
Y.S Avatar asked Mar 23 '17 06:03

Y.S


People also ask

What is multidex Android studio?

In Android, the compilers convert your source code into DEX files. This DEX file contains the compiled code used to run the app. But there is a limitation with the DEX file. The DEX file limits the total number of methods that can be referenced within a single DEX file to 64K i.e. 65,536 methods.

Is multidex needed?

Multidex support library is enabled by default in API level higher than 21 (Android 5 and higher). Therefore, you do not need to add the Multidex support library.


2 Answers

I have passed the building. my solution is that adding explicit dependencies in build.gradle. compile 'com.android.support:multidex:1.0.1'

like image 187
Thomas Liu Avatar answered Sep 28 '22 11:09

Thomas Liu


The solution to this problem is to add the following:

dependencies {   implementation 'com.android.support:multidex:1.0.3' } 

in your build.gradle file.

This was not required prior to Gradle 3.3. This problem occurs only for apps that support Android versions below Lollipop (API level 21).

References:

1. Multidex support prior to Android 5.0.

like image 32
Y.S Avatar answered Sep 28 '22 11:09

Y.S