Android Multi-dex Enable

Home  >>  Tutorials  >>  Android  >>  Android Multi-dex Enable

Android Multi-dex Enable

3
Dec,2016

0

aSometimes it needed to enable multidex in out add and its can throw error also . But memory limit 64 k problem may be a painful problem to solve for who faces this problem newly .

But we can easily solve this problem . Just three steps –

Step : 1

Add dependency at first and sync

compile 'com.android.support:multidex:+'

Step 2 :

and add multidex enable inside defaultConfig

multiDexEnabled true

so whole build.gradle will looks like as

 

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.3"
    defaultConfig {
        applicationId "com.example.arifhasnat.googlemapapi"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.google.android.gms:play-services:9.6.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:+'
}

Step 3 :

And finally give the the app name inside application of manifest

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

as like

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:name="android.support.multidex.MultiDexApplication"
    android:theme="@style/AppTheme">

Now run the program . Hope it will work fine 🙂

 

Details :

https://developer.android.com/studio/build/multidex.html

Leave a Reply

Your email address will not be published. Required fields are marked *