Android: Gradle - Module Dependency Issue - Unable to find symbol

There are two modules in the Android project

  1. app
  2. database

database build.gradle:

dependencies {
    implementation 'com.sample.lib:lib-v7:27.1.1'

}

app build.gradle:

dependencies {

        implementation project(':database')
    }

Now in the app I am able to get references to the files in sample lib. But when the apk is to be built i get the following error:

error: cannot find symbol class SampleLibClassA

Why am I getting this error even when database module is added to app module as a dependency?

It works if I add the SampleLib dependency separately again the app module. But doesn't that defeat the whole purpose and wouldn't that just mean duplicate dependencies. Why is there a need to add them separately? Am I missing something here?

Thanks.

1 answer

  • answered 2018-07-11 05:30 IntelliJ Amiya

    Make sure the library is listed at the top of your settings.gradle file, as shown here for a library named "database"

    include ':app', ':database'