1

My project have two modules:

  • App
  • Facebook-lib

Here are my gradle files:

setting.gradle

include ':app', ':facebook-lib'

Module App gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.app.test"
    minSdkVersion 18
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:appcompat-v7:22.1.1'
  compile project (':facebook-lib')

}

Module Facebook-lib gradle

apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    minSdkVersion 18
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'

}

Whenver I am trying to access Facebook-lib class in App module. It works but I can't do vice versa. I get com.app.testpackage doesn't exist or cannot find symbol class.

What I am doing wrong here?

Community
  • 1
  • 1
  • So you are trying to comunicate to `App` module from `Facebook-lib` module, aren't you? In that case add the compile dependency in the Facebook-lib `build.gradle`. Anyway, I don't think that is a good practice since you are creating circle dependencies. There must be a better way to do what you are trying to – Alberto S. Aug 28 '15 at 10:18
  • Yes, It will create a circular dependencies but still it's not compiling –  Aug 28 '15 at 10:28
  • You can't create a circular dependency. – Gabriele Mariotti Aug 28 '15 at 11:19
  • http://stackoverflow.com/questions/32438751/how-to-communicate-between-lib-module-and-main-module might help – debug.error Mar 11 '17 at 10:32

1 Answers1

0

You can't achieve it.

Your Module App has a dependency with the Module Facebook library. It means that you can use the classes inside the library in your main module.

Your Facebook library doesn't have a dependency with your module. It means that you can't use the classes in main module.
Also you can't create a circular dependency.

Angela
  • 316
  • 2
  • 10