ema3272
ema3272

Reputation: 1051

Android Studio 3: how do I import a source code library into a project

The build.gradle in the appfolder contains the following code:

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

The settings.gradle file in the project folder contains:

include ':app', ':sclibrary'
project(':sclibrary').projectDir = new File(rootProject.projectDir, '../sclibrary4')

When I synchronize my project I get an error that says "Missing dependencies: unable to find module with Gradle path ':sclibrary' (needed by module 'app'.)"

EDIT:

"sclibrary4" is located in the folder as the "sc" and "ScLite" applications; these applications use common code located in "sclibrary4" file structure

When I try to use the "File>New>Import Module" command, I get the error message "This location is already imported" although

enter image description here

and

enter image description here

Upvotes: 8

Views: 2301

Answers (1)

Boni2k
Boni2k

Reputation: 3305

Something like this can be fixed with:

  • remove project dependency from settings.gradle file
  • remove dependency from build.gradle
  • gradle sync
  • Android Studio should show an info that a dependency has been removed
  • add dependencies again

This worked for me on several occasions, e.g. with Android Studio 3.1.2

Upvotes: 5

Related Questions