Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

android - Sync shared library projects/modules with its source

I am learning to build Android shared libraries that can be used with different projects. I got a few questions regarding this subject. Before I go into the questions, below is what I have done so far:

  • Create a library project
  • Create another application project and import above library as a module

My questions are:

  • Is the library project's code automatically synchronized with the one imported into application projects? How it can be achieved?
  • If not, what else I can do to make sure I just need to update the shared library once?

I am using Android Studio IDE.

Thank you,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ah yes, this can be very helpful in many cases. You can do the following to achieve this.

Let's say you have two projects - MyApplication and MyLibraryDemo containing the library module libmodule with the following paths:

MyApplication - "/../AndroidStudioProjects/MyApplication"

MyLibraryDemo - "/../AndroidStudioProjects/MyLibraryDemo"

libmodule - "/../AndroidStudioProjects/MyLibraryDemo/libmodule"

And let's say you are trying to use libmodule in MyApplication. Then, in your settings.gradle of your MyApplication project, do this

include ':app', ":libmodule"
project(':libmodule').projectDir = new File(settingsDir, '../MyLibraryDemo/libmodule')

You may have to make relevant corrections, but I hope the idea of linking another module is clear.

All the best :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...