8

I followed the multidex guide at https://developer.android.com/tools/building/multidex.html

But I get this error Gradle DSL method not found : 'multiDexEnabled()' . I have updated Android Built Tools , Android Support Repository and Library. Here is my gradle.build file. Am I doing something wrong here?

Could not find method multiDexEnabled() for arguments [true] on ProductFlavorDsl_Decorated{name=main, minSdkVersion=ApiVersionImpl{mApiLevel=10, mCodename='null'}, targetSdkVersion=ApiVersionImpl{mApiLevel=17, mCodename='null'}, renderscriptTargetApi=-1, renderscriptSupportMode=null, renderscriptNdkMode=null, versionCode=-1, versionName=null, applicationId=test.com.app, testApplicationId=null, testInstrumentationRunner=null, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null}.

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "test.com.app"
        minSdkVersion 10
        targetSdkVersion 17

        // Enabling multidex support.
        multiDexEnabled true
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':addThisSDK')
    compile project(':centeredContentButton')
    compile project(':googleplayservices_lib')
    compile files('libs/addthis0.0.8.jar')
    compile files('libs/adxtag2.4.6.jar')
    compile files('libs/android-support-v4.jar')
    compile files('libs/aws-android-sdk-1.7.1.1-debug.jar')
    compile files('libs/commons-lang-2.6.jar')
    compile files('libs/crittercism_v4_4_0_sdkonly.jar')
    compile files('libs/dd-plist.jar')
    compile files('libs/FiksuAndroidSDK_4.1.1.jar')
    compile files('libs/iqengines-sdk-barcode.jar')
    compile files('libs/irEventTracker-1.2.jar')
    compile files('libs/jolt-core-0.0.7.jar')
    compile files('libs/json-utils-0.0.7.jar')
    compile files('libs/jsoup-1.7.2.jar')
    compile files('libs/kooaba-api-v4-java.jar')
    compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
    compile files('libs/signpost-core-1.2.1.1.jar')
    compile 'com.android.support:multidex:1.0.0'
}
Snicolas
  • 37,840
  • 15
  • 114
  • 173
bman
  • 3,740
  • 9
  • 34
  • 40

6 Answers6

17

I also received this error when I placed the multiDexEnabled true command in the wrong location. Make sure it's in the defaultConfig code block:

android {
    ...

    defaultConfig {
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
}
TheIT
  • 11,919
  • 4
  • 64
  • 56
6

Make sure the dependencies in your app's gradle file have this lines:

dependencies {
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'

}

Also, in your global (Project) gradle file, make sure you have the latest gradle version.

dependencies {

    classpath 'com.android.tools.build:gradle:0.14.0'
}

In your SDK manager, make sure you have the latest support libraries and repo.

In your AndroidManifest.xml. add the following line:

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

You can read the entire documentation here.

Roberto Betancourt
  • 2,375
  • 3
  • 27
  • 35
  • So that this is clear, you actually do not need to add that to your manifest if you are extending application. In that case you should add @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } – portfoliobuilder Jan 13 '15 at 21:30
  • Also, this should be selected answer – portfoliobuilder Jan 13 '15 at 21:31
4

You have to be running version 0.14.0 or later of the Android Gradle plugin. See the release notes at http://tools.android.com/tech-docs/new-build-system for details on what's in each release.

Scott Barta
  • 79,344
  • 24
  • 180
  • 163
  • 1
    Thanks I updated to latest Android Studio (Canary 0.9.2) and latest Android Gradle Plugin 0.14.2 – bman Nov 13 '14 at 23:14
  • @Scott Barta i am using Android studio 1.0 RC 4 but shows me the error as Gradle DSL method not found:'useOldManifestMerger()' i had removed it and run now it shows as Gradle DSL method not found:'apply()' – Manoj Dec 08 '14 at 06:45
  • @Manoj start a new question and include your build file details. – Scott Barta Dec 08 '14 at 17:04
2

Set

minSdkVersion 21

This worked form me.

Mystery
  • 163
  • 1
  • 10
0

In app/build.gridle under defaultConfig add:

defaultConfig {
   
    ...
    multiDexEnabled true
    ...
}

Then, at the bottom, add this code exactly like this if you dont have dependencies block already:

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

Finally, in pubspec.yaml under dependencies add:

firebase_core: ^0.5.0+1

After these changes your app should work properly.

karora
  • 1,223
  • 14
  • 31
-1

Make sure that you have android:name="android.support.multidex.MultiDexApplication" in your Android manifest file in the application element.

Joel
  • 14,861
  • 3
  • 27
  • 31
  • 1
    can't even recognize MultiDexApplication as the build.gradle file does not build. – bman Nov 13 '14 at 12:19