Shahnaz Khan Shahnaz Khan - 8 days ago 6
Android Question

Gradle project sync failed for android support multidex library

I am trying to add Multidex library to my project. I added following as dependency in my 'app/build.gradle' -

complie 'com.android.support:multidex:1.0.1'


when i try to sync i can see following error

Error:Could not find method complie() for arguments [com.android.support:multidex:1.0.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.


i have Android Support Repository installed.

SDK Manager snapshot

Can someone help me? Thanks in Advance.

Answer

add multiDexEnabled = true in your build.gradle

android {
defaultConfig {
    ...
    multiDexEnabled = true
}
}

dependencies {
  ...
  compile 'com.android.support:multidex:1.0.0'
  ...
}

add this to manifest file

android:name="android.support.multidex.MultiDexApplication"

and your Activity class

    protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
     }
Comments