TrinityTuts Tips

Fix MultiDex Issue or Building Application over 65K

In this tip i show you how to fix multidex error when you building android application this error occur when you add multiple library and the space they need is not available. I also face this issue when i add fabric crashlytics in my android application and here below what i do to solve this issue open build.gradle file and add below code i add comment above a change in my project gradle so you can easily add those line in you file.

Fix MultiDex Issue or Building Application over 65K

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
//Add this two line
    dexOptions {
        javaMaxHeapSize "1g"
    }
    defaultConfig {
        applicationId "com.trinitytuts"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 3
        versionName "2.2"
//Enable multiDex 
        multiDexEnabled true
    }
//Add this Line
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
    allprojects {
        repositories {
            maven { url "https://jitpack.io" }
            maven { url 'https://maven.fabric.io/public' }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

after adding these lines in your code for first time when you run your app it take some time but for next time it run fast and take normal time. Hope this will fix your issue 🙂