Solution to multiple Android studio projects referencing the same library project configuration

When developing with Android studio, if multiple projects reference the same library, there will be a set of library code in each project. The Library under development and maintenance needs to be modified frequently, which is very annoying for synchronization. In order to solve this problem, the following solutions appear.

First: create a new class library project named applibs.dev.

This class library contains the module of a public class library applibs. The build.gradle configuration under the module is as follows:

After such a class library project is completed, the next step is to reference the project containing the class library.

Secondly: reference the class library project. Create a new testproject project through Android studio, as shown below.

The following three things need to be done in the project:

1. Add the code with a red box in the project settings.gradle.

2. Add the code with red box in the build.gradle file of module:

If the class library project contains multiple modules, add the following code after the original code in the settings.gradle file:

include ':AppLibs.Dev:moduleName'

At the same time, add the corresponding module code to build.gradle in app module:

compile project(':AppLibs.Dev:moduleName')

3. Click build - > clean project in the menu of Android studio. After cleaning, you will see the following figure.

After completion, as shown in the figure above, it means that the class library project has been referenced by the app project. In this way, the source code in the class library project will be modified in the future, and the source code in other projects that reference the class library will be modified synchronously.

summary

The above is the Android studio multi project introduced to you by Xiaobian, which refers to the configuration method of the same library project. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>