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

8

46

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?

Mastoiditis answered 23/3, 2017 at 6:58 Comment(5)
try this answer once,not sure if it will work, just check onceScutari
just go to settings>build, execution, deployment>gradle> and select "Use default gradle wrapper (recommended)" then rebuildSeline
@ScottS: I have already tried that but it doesn't work.Mastoiditis
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 helpSeline
compile 'com.android.support:multidex:1.0.1' try add that to dependencies in build.gradleMontparnasse
M
48

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.

Mastoiditis answered 4/10, 2017 at 8:7 Comment(1)
implementation 'com.android.support:multidex:1.0.3' developer.android.com/studio/build/multidex.html#mdex-pre-lGird
J
70

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

Jostle answered 31/3, 2017 at 7:4 Comment(0)
M
48

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.

Mastoiditis answered 4/10, 2017 at 8:7 Comment(1)
implementation 'com.android.support:multidex:1.0.3' developer.android.com/studio/build/multidex.html#mdex-pre-lGird
S
10

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

Silicious answered 19/3, 2020 at 7:43 Comment(0)
C
9

I know this is old question but web searching got me here. As of flutter 3.22, (if upgraded from earlier flutter with multidex already enabled) there is a file that needs deleted FlutterMultiDexApplication.java

ref: https://github.com/flutter/flutter/issues/148368

Coachman answered 17/5 at 8:43 Comment(1)
If App was fine until 3.22 then this is your solutionFuss
J
8

Had this issue after updating to Flutter 3.22. @Paul Charlton's solution worked for me.

Deleting FlutterMultiDexApplication.java found at \android\app\src\main\java\io\flutter\app

Jasperjaspers answered 18/5 at 23:2 Comment(0)
D
3

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

dependencies {

implementation 'androidx.multidex:multidex:2.0.1'

}
Drawing answered 18/10, 2022 at 18:39 Comment(0)
L
3

Pretty Working Solution(June 2024)

By simply deleting the FlutterMultiDexApplication.java file, I was able to run the app properly. It worked for me. The file is located at android/app/src/main/java/io/flutter/app

Langmuir answered 23/6 at 17:48 Comment(0)
B
-1

In addition to:

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

It is necessary to add this:

defaultConfig {
    ...
    multiDexEnabled true
}
Biosphere answered 13/9, 2022 at 16:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.