Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Android studio project as module

My Image

I want to import a android studio project into another android studio project. so i have imported it as module in the android studio project. this message project already have module that are used in the project. i have imported message project in android studio successfully. but when i adding a dependency it is not showing this module, so please check image that i have imported and how can i add dependency of message module.

I have tried

implementation project(':message')

But getting a error

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :message. Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :message.

Show Details Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :message. Show Details Affected Modules: app
like image 320
Rover Avatar asked Oct 15 '22 13:10

Rover


1 Answers

You should have a structure like this:

   -rootApp
    |--build.gradle
    |--settings.gradle
    |--app
    |----build.gradle

    -rootMessage
    |--build.gradle
    |--settings.gradle
    |--vcard
    |----build.gradle

Inside a project you can refer an external module.

Just use:

In rootApp/settings.gradle:

include ':app' 
include ':myExternalLib'
project(':myExternalLib').projectDir=new   File('/path-to-project/rootMessage/vcard')

In app/build.gradle:

dependencies {
    implementation project(':myExternalLib')
}

Pay attention to myExternalLib.
You have to use the path of the library inside the other project, not the root of the project.
In your case the path is rootMessage/vcard.
Also,the rootMessage/settings.gradle will not be read because you are using the rootApp project.

like image 105
Gabriele Mariotti Avatar answered Oct 20 '22 22:10

Gabriele Mariotti