Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Multidex with Gradle

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 359
    Comment on it

    When our application and libraries references reaches their limits, then we get some errors that shows we reached the limit of built architecture.

    Like this

    trouble writing output:
    Too many field references: 131000; max is 65536.
    You may try using --multi-dex option.

    So we need to configure Multidex with Gradle

    This plugin available for Android SDK Build Tools 21.1 and higher for Gradle. We need to do just small modifications for it.

    There is the modification in gradle file.
    add one dependency for multidex and enable multiDex in defaultConfig.

    
    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.0"
    
        defaultConfig {
            ...
            minSdkVersion 14
            targetSdkVersion 21
            ...
    
            // Enabling multidex support.
            multiDexEnabled true
        }
        ...
    }
    
    dependencies {
      compile 'com.android.support:multidex:1.0.0'
    }


    In manifest, just add MultiDexApplication class to the application element.

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.android.multidex.myapplication">
        <application
            ...
            android:name="android.support.multidex.MultiDexApplication">
            ...
        </application>
    </manifest>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: