Android Libraries in Android Studio

后端 未结 6 1331
长发绾君心
长发绾君心 2020-12-14 17:44

Has anyone figured/found out how Android libraries are intended to work in Android studio?

I have not been able to find any documentation on this yet (the documentat

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 18:13

    For the sake of anyone hitting on this, here's what I'm doing to "solve" this issue. It's very far from an elegant solution, IMO, but it's the closest to a good solution that I've found for handling my problem (reusing Android libraries) in Android Studio with Git.

    Basic idea is to use Git submodules. Each library has it's own Git repository.

    1. Create myLibrary as a module, and then commit it to a repository.
    2. From the project root repository, I do an git submodule add to fetch the library.
    3. In settings.gradle, I add: include ':myLibrary' and sync the project.
    4. Module Settings >> Dependencies >> + Module Dependency and add a dependency to the module as appropriate.

    It's a far cry from the simple elegance of working with Android libraries in Eclipse, but it works after a fashion. Things to keep in mind:

    • remember to git pull frequently, to pick up changes (and then commit the main project to sync with the submodule changes).
    • remember to git push from the module directory to remote, if you've committed changes to the library.

    The built-in VCS should be able to help here, but it's been pretty flaky for me, so I prefer to just do it myself from a terminal now.

    Hope this helps.

提交回复
热议问题