简体   繁体   中英

How to add a local module as dependency to a project in Android Studio?

How can I add a module of a local project as dependency to another project?

I tried the following:

  1. Add to settings.gradle :
include ':app', ':module'
project(':module').projectDir = new File('/path/to/module')
  1. Add to project build.gradle :
buildscript {
    dependencies {
        ext { compileSdkVersion = 31; minSdkVersion = 19; targetSdkVersion = 31 }
    }
}
  1. Add to app build.gradle :
dependencies {
    implementation project (":module")
}

But this fails to build with error:

Build file '/path/to/module/build.gradle' line: 3

A problem occurred evaluating project ':module'. Plugin with id 'com.some.lib' not found.

I can build the module project without any issues with ./gradlew publishToMavenLocal , but how can I build it automatically as part of the parent project?

The goal is to develop the module and test the changes immediately in an example app.

The way I do it now is publish the module to local maven and let local maven override the dependency in the example app, but I wonder if there is a more direct way that automatically builds the module and where I can even debug-step through the module while testing it in the example app.

Remove the space after colon : on line#2 in settings.gradle

It should be project(':module') but you have written project(': module')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM