I'm Using Dagger 2.11 with Android Injection support. After adding a big amount of dependencies i was forced to enable MultiDex.
The support for Multidex was added, on Android 4.4 works as expected, on Android >=6 works great.
The problem appears only on Android 5 and 5.1 i get the following error:
Caused by: java.lang.ClassNotFoundException: Didn't find class "dagger.internal.Preconditions" on path: DexPathList[[zip file...
I tryed to add the "dagger.internal.Preconditions" to the file i use in multiDexKeepProguard, with no luck.
The build.gradle file
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
repositories {
    maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.tmiyamon.config'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.tmiyamon.config'
apply plugin: 'realm-android'
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "appId"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }
    dexOptions {
        preDexLibraries false
        javaMaxHeapSize "4g"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    signingConfigs {
        debug {
            storeFile file("path")
            keyAlias "alias"
            storePassword "password"
            keyPassword "password"
        }
        release {
            storeFile file("path")
            keyAlias "alias"
            storePassword "password"
            keyPassword "password"
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            minifyEnabled false
            zipAlignEnabled false
            testCoverageEnabled false
            multiDexKeepProguard file('multidex-config.pro')
            proguardFiles fileTree(dir: 'proguard').asList().toArray()
        }
        release {
            minifyEnabled true
            multiDexKeepProguard file('multidex-config.pro')
            proguardFiles fileTree(dir: 'proguard').asList().toArray()
            signingConfig signingConfigs.release
        }
    }
    productFlavors {
        local {
            applicationIdSuffix ".local"
            versionNameSuffix " Local " + calculateVersionNameSuffix()
        }
        staging {
            applicationIdSuffix ".staging"
            versionNameSuffix " Staging " + calculateVersionNameSuffix()
        }
        production {
        }
    }
}
dependencies {
long list of dependencies
}
and the Manifest file:
<manifest package="package"
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools">
<<   permissions >>
<!--${applicationId}-->
<application
    android:name=".application.MyApplication"
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="${launcherAppName}"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:replace="android:label">
    <activity
        android:name=".ui.startup.StartupActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
rest of the Manifest....
Well, in the end, I found a solution.
I've added also the
multiDexKeepFile file('multidex-config.txt')
into the buildTypes part of the buiild.gradle file.
Now it looks like below:
 release {
        minifyEnabled true
        zipAlignEnabled true
        multiDexKeepFile file('multidex-config.txt')
        multiDexKeepProguard file('multidex-config.pro')
        proguardFiles fileTree(dir: 'proguard').asList().toArray()
        signingConfig signingConfigs.release
        debuggable false
    }
and the multidex-config.txt has the following:
dagger/internal/Preconditions.class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With