android-studio-import

Class Not found when try to acces the class in the library of a android module from another Android module


I have a Android library module (Common), which has a library dependency (com.android.support:multidex:1.0.1). Alongside "Common" module I have an Android module (Module1)ich requires "MultiDex" (located as dependency within the "Common" Library Module), but I get an error: android.support.multidex.MultiDex does not exist.

Common Library build.gradle:

apply plugin: 'com.android.library'

dependencies {
    compile 'com.android.support:multidex:1.0.1'
}

Module1 build.gradle:

dependencies {
    compile project(':Common');
}

But in Module1 i am unable to use MultiDex


Solution

  • In your build.gradle you need to enable multidex as:

    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'
    }
    

    Hope this helps..