Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add application module dependency into another application module in Android Studio with Gradle

Is it possible to have 2 applications modules (with apply plugin: 'com.android.application' at the head of their gradle file) and one having a dependency over another?

So module A would have a dependency to module B and both would be applications.

dependencies {
    ...
    compile project(':moduleB')
}

I easily managed to add this dependency and no errors/warnings comes out but I still do not have access to source files inside moduleB. Android Stduio still suggest me to "add dependency to moduleB" and when I do it just re-syncing gradle and nothing happen.

I tried to include a dependency over a library module and this is working fine. Can't we add dependency between two (or more) applications modules?

like image 470
MHogge Avatar asked Jan 25 '17 14:01

MHogge


People also ask

How do I add a dependency in Gradle?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.

How do I import a module into Gradle?

In Android Studio, Right-clicking on the folder to add as library. Editing the dependencies in the build. gradle file, adding: compile fileTree(dir: 'libs', include: '*. jar')}

How do I sync Gradle with Android Studio?

Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.

Can we import module in Android Studio?

Import a module To import an existing module into your project, proceed as follows: Click File > New > Import Module. In the Source directory box, type or select the directory of the module(s) that you want to import: If you are importing one module, indicate its root directory.


1 Answers

Is it possible to have 2 applications modules (with apply plugin: 'com.android.application' at the head of their gradle file) and one having a dependency over another?

No, sorry.

Can't we add dependency between two (or more) applications modules?

Correct — that is not supported.

like image 84
CommonsWare Avatar answered Sep 23 '22 17:09

CommonsWare