简体   繁体   English

在Android Studio中包含库项目

[英]Include library project in Android Studio

I have around 49 android apps. 我有大约49个Android应用程序。 All of them have a reference to one library project. 他们都参考了一个图书馆项目。 Till now, I have been developing on eclipse. 直到现在,我一直在开发日食。 Now, I am moving to Android Studio. 现在,我正在转向Android Studio。 What's the way to reference a library project in Android Studio? 在Android Studio中引用库项目的方法是什么?

I tried the answer mentioned in How to include library projects in Android Studio that are stored in a separate git repository? 我尝试了如何在Android Studio中包含存储在单独的git存储库中的库项目中提到的答案

This actually copies the library project within the app project. 这实际上是在app项目中复制库项目。 So, If i change anything in the library, it will not be reflected in 48 other apps. 所以,如果我更改了库中的任何内容,它将不会反映在其他48个应用程序中。

How about creating a library project , then adding it to Bintray and including in your projects dependencies? 如何创建一个库项目 ,然后将其添加到Bintray并包含在您的项目依赖项中?

Follow this guide up to the point where you'll be able to include your library like this: 按照本指南 ,您可以像这样包含您的库:

repositories {
    maven {
        url 'https://dl.bintray.com/$DEVELOPER$/maven/'
    }
}

...

dependencies {
    compile 'groupId:artefact:0.0.1'
}

Then consider sharing it on jCenter / mavenCentral. 然后考虑在jCenter / mavenCentral上共享它。

Beware, that sharing code privately on Bintray is not free. 请注意,在Bintray上私下共享代码并不是免费的。 This solution would be really optimal for opensource library though 这个解决方案对于开源库来说确实是最佳的

you can have your library code in git and add it to your application projects as a sub module. 您可以将您的库代码放在git中,并将其作为子模块添加到您的应用程序项目中。 so if you modify the library from one project you can push the changes to the library git and then from other application you can pull those changes. 因此,如果您从一个项目修改库,您可以将更改推送到库git,然后从其他应用程序中提取这些更改。 it would be better to keep separate branch of library for each application so as not to conflict with the usage on modification. 最好为每个应用程序保留独立的库分支,以免与修改时的使用冲突。

i have explained the steps to add a git library as a sub module in here: Android Studio, how to add my own git repository as a library project(sub module)? 我已经解释了在这里添加git库作为子模块的步骤: Android Studio,如何将我自己的git存储库添加为库项目(子模块)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM