gradle – Multiple android projects within a directory-ThrowExceptions

Exception or error:

I have two android applications within a directory:

MessageBroker (directory)[No build.gradle files and settings.gradle file]

|—> helloworld (android application)

|—> tflitedetector(android application)

The above two projects builds successfully individually.

Now, I have a repository of android apps(example_applications) within which I want to include this MessageBroker repository and build it successfully.This example_applications repo has several other android applications, which I include in settings.gradle using the following lines:

rootProject.name = 'apps'

def messagebrokerhelloworld="$rootDir/MessageBroker/helloworld"
def messagebrokertflitedetector="$rootDir/MessageBroker/tflitedetector"
// All example applications listed here will be used by the build.gradle script
// to build and distribute.
include ':helloworld'
include ':tflitedetector'
include ':virtualcameramanager'
include ':opencvfacedetection'

//These lines are for including MessageBroker
include ':MessageBroker'
project(':MessageBroker').projectDir = new File(messagebrokerhelloworld)
project(':MessageBroker').projectDir = new File(messagebrokertflitedetector)

Using the above, the project gets included and the gradle build succeeds.But running the command gradlew assembleDebug gives the following error:

  • What went wrong:
    Project directory ‘/home/sayandey/AndroidStudioProjects/example_apps/MessageBroker’ is not part of the build defined by settings file ‘/home/sayandey/AndroidStudioProjects/example_apps/settings.gradle’. If this is an unrelated build, it must have its own settings file.

Can someone kindly help me out about how to make the build succeed?

Thanks.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *