zoukankan      html  css  js  c++  java
  • Tutorial for adding a library project as git submodule and then using it as a studio Module

    https://gitsubmoduleasandroidtudiomodule.blogspot.in/
    I'm writing this blog to make the development process easy and faster. This is specific to Android Studio, same can be used for any other project which used Gradle build system and GIT.

    I want to make all the reusable components of my current application as library so that it can be used by the new applications as and when required. This will also be useful for Android Instant Application which Google announced recently because they propose to develop the application as modular as possible so that they will download only the modules required to view the particular page.

    I suggest to keep all the libraries in separate GIT repos and add them as a GIT sub module in main application project. Hence whenever we need these reusable components in any other application it can be easily used.

    After these libraries has been added as git submodule in the application project we can make changes in the build.gradle to use them as Modules in Application Gradle Project.

    Advantages

    1. Usually we will be making changes to both library and the application project. This setup would be really helpful to make changes to both in the same gradle project.
    2. We don't need to create AAR / JAR files and update the libs for the changes we do in the library project.
    3. We can always pull the latest changes in our repo from the remote branch if there are other contributors in this repo.


    Tutorial for adding a library project

    In this example I'm adding Volley as my networking library. I'm using official Volley GIT repo so that anyone interested can add this library for their application.

    Step I : Add volley as submodule in Android application project GIT Repo.
    git submodule add -b master https://android.googlesource.com/platform/frameworks/volley Libraries/Volley

    Step II : In settings.gradle, add the following to add volley as a studio project module.
    include ':Volley'
    project(':Volley').projectDir=new File('../Libraries/Volley')

    Step III : In app/build.gradle, add following line to compile Volley
    compile project(':Volley')

    That would be all! Volley has been successfully added in the project.
    Every time you want to get the latest code from Google official Volley's repo, just run the below command
    git submodule foreach git pull

    Git hub repo for the sample project
    https://github.com/arpitratan/AndroidGitSubmoduleAsModule/

    Commit containing changes for Library project
    https://github.com/arpitratan/AndroidGitSubmoduleAsModule/commit/d819eae73b88d4b744b20836e636e3f7460ec774

  • 相关阅读:
    BZOJ 1027: [JSOI2007]合金 (计算几何+Floyd求最小环)
    BZOJ 4522: [Cqoi2016]密钥破解 (Pollard-Rho板题)
    BZOJ 4802: 欧拉函数 (Pollard-Rho)
    BZOJ 3944: Sum (杜教筛)
    BZOJ 3309: DZY Loves Math (莫比乌斯反演)
    BZOJ 2599: [IOI2011]Race(点分治板题)
    BZOJ 3680: 吊打XXX // Luogu [JSOI2004]平衡点 / 吊打XXX (模拟退火)
    Luogu P3690【模板】Link Cut Tree (LCT板题)
    [HNOI2007]最小矩形覆盖
    [SCOI2007]最大土地面积
  • 原文地址:https://www.cnblogs.com/qike/p/5689783.html
Copyright © 2011-2022 走看看