Wednesday, April 23, 2014

Gradle Android : Multiple project setup

For a Multi-project setup, the Android documentation for gradle states :
"A multi-project setup usually works by having all the projects as sub folders of a given root project."

MyProject/
 + app/
 + libraries/
    + lib1/

But I have a different situation where my library project and the actual project is not under the same root.

So, my library project is inside its own directory. Then I have my main project in some other directory wanting to refer to this library project. I had a hard time to figure this out with gradle. So, hopefully this helps someone.

So basically, the structure is as follows:

~/Dev/Libraries
    |---- foolib-root
                |---- foolib
                           |---- build.gradle
                           |---- src
                           |---- libs
                |---- build.gradle
                |---- settings.gradle


~/Dev/Projects
    |---- project1-root
                |---- project1
                           |---- build.gradle
                           |---- src
                           |---- libs
                |---- build.gradle
                |---- settings.gradle


Just, FYI, the build.gradle inside foolib-root/foolib contains:

apply plugin: 'android-library'

indicating that it is a library module.

Now, the task is to refer to library project foolib from project1.

I have found there are 2 things you need to do to achieve this:

1. The settings.gradle in project1-root must define the library project in its scope and provide a path for it. You can do this by having the following line in it:

 project(':foolib').projectDir = new File(settingsDir, '../Libraries/foolib-root/foolib')

2. Add this library project into the dependencies of project1 by adding the following to its build.gradle:

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

This did the trick for me. Not sure if this is a right way to do it. But serves my purpose.

3 comments:

  1. Hi,

    Very Nice Blog.
    Thanks for sharing sunch an amazing Information here.Please continue,keep posting More updates.
    android app development course
    android course online

    android training

    android online training

    ReplyDelete
  2. Step into the world of possibilities with free local classified ads in India. Elevate your buying and selling experience effortlessly. Post free classified ads and unlock a marketplace where community meets convenience. It's your chance to seamlessly connect, trade, and discover treasures in your neighborhood. Explore, engage, and empower your local connections today.

    ReplyDelete
  3. A Forex funding account with FundedFirm opens doors for traders who want to trade large capital without risking their own money, providing a platform to develop and monetize trading skills. FundedFirm offers a clear and fair evaluation process, which assesses consistency, risk management, and profitability to qualify traders for funded accounts. Once qualified, traders access real capital to trade forex, commodities, indices, and cryptocurrencies on platforms like MT4 and MT5, benefiting from low spreads and fast execution. FundedFirm rewards traders with competitive profit-sharing models, rapid payout systems, and scalable funding options that increase capital allocation as success is demonstrated. Further, FundedFirm offers continuous education and professional support, nurturing sustainable growth. With this model, traders overcome capital constraints and focus fully on strategy and performance, helping them transform their trading into a reliable income stream. A forex funding account with FundedFirm is more than just access to capital—it’s a pathway to financial independence and professional trading success, empowering traders worldwide to thrive in the competitive forex market.

    Forex Funding Accounts

    ReplyDelete