38

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?

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • try this [answer](http://stackoverflow.com/a/41479407/6478047) once,not sure if it will work, just check once – Manohar Mar 23 '17 at 07:16
  • just go to settings>build, execution, deployment>gradle> and select "Use default gradle wrapper (recommended)" then rebuild – HaroldSer Mar 23 '17 at 07:33
  • @ScottS: I have already tried that but it doesn't work. – Yash Sampat Mar 23 '17 at 07:44
  • in your build.gradle do you have multidex enabled and if so have you imported multidex library as part of the dependencies? com.android.support:multidex:x.x.x' in your manifest do you have this line added? package="com.example.android.multidex.myapplication" within manifest tag? post your gradle and your manifest if still need help – HaroldSer Mar 23 '17 at 08:05
  • 2
    compile 'com.android.support:multidex:1.0.1' try add that to dependencies in build.gradle – Robert Rowntree Mar 23 '17 at 08:11

5 Answers5

68

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

Thomas Liu
  • 821
  • 1
  • 7
  • 5
39

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.

Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • `implementation 'com.android.support:multidex:1.0.3'` https://developer.android.com/studio/build/multidex.html#mdex-pre-l – Chaki_Black May 15 '20 at 04:46
10

Replace
import android.support.multidex.MultiDexApplication;
with
import androidx.multidex.MultiDexApplication;

Shehzad Osama
  • 1,222
  • 12
  • 13
1

what works for me is adding to your (app) build.gradle

dependencies {

implementation 'androidx.multidex:multidex:2.0.1'

}
Wowo Ot
  • 1,362
  • 13
  • 21
0

In addition to:

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

It is necessary to add this:

defaultConfig {
    ...
    multiDexEnabled true
}