0

It gives these errors when I try to run the app. Can anybody help me please?

enter image description here

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95

1 Answers1

1

The total number of methods that can be referenced within a single DEX file is limited. That's why you should enable Multidex. Make the following changes in your module-level build.gradle file:

    android {
        ....
    
        defaultConfig {
            ...
            multiDexEnabled true
        }
    
    dependencies {
        ...
        implementation "androidx.multidex:multidex:2.0.1" // if you're using AndroidX
        implementation 'com.android.support:multidex:1.0.3' // or add this one if you don't use AndroidX
    }

You might also need to change your application class file:

  1. If you don't use your own Application class, add the following line to your AndroidManifest.xml file:
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.yourapp">
        <application
                ...
                android:name="androidx.multidex.MultiDexApplication" >
            ...
        </application>
    </manifest>
  1. If you override the Application class, make sure your class extends MultiDexApplication:
    public class MyApplication extends MultiDexApplication {
        // your app code
    }

More details about Multidex you can find here.

OLezhko
  • 150
  • 3