在 Studio/SDK 的默认库列表中添加一个 android 库 [英] Add an android library to the default list of libraries in Studio/SDK

查看:33
本文介绍了在 Studio/SDK 的默认库列表中添加一个 android 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以首先,为了消除任何疑问,我知道如何将库添加到 android 项目.我的问题是,我想将一个库添加到我的 android studio 中的默认库列表中.

So first of all, just to clear any doubts, i know how to add a library to an android project. My question here is that, i want to add a library to the list of default libraries in my android studio.

让我用一个例子来解释.假设我想将 Glide 库添加到我的项目中.首先,我必须转到 glide github 页面,然后从那里复制 compile 'com.github.bumptech.glide:glide:3.7.0' 文本并粘贴到我的build.gradle 文件.然后 android studio 将通过互联网下载库.所以每次我想在我的任何项目中使用 Glide 库时,我都必须这样做.我想要的是,我想在我可用的默认库列表中包含一个像 Glide 这样的特定库

Let me explain with an example. Let's say i want to add the Glide library to my project. To do that firstly, i have to go to glide github page and then, from there i copy the compile 'com.github.bumptech.glide:glide:3.7.0' text and paste in in my build.gradle file . Then the android studio would download the library over the internet. So every time i want to use the Glide library in any of my project, i have to do this. What i want , is that, i want to include a specific libary like Glide in my Default list of libraries that are available to me

所以在这里,我想包含我的库项目,以便我可以在我的任何项目中使用它.在此先感谢您的阅读.

So Here, is where i want to include my library project, so that i can use it, in any of my projects. Thanks in advance, for reading.

推荐答案

有一种方法可以将库自动添加到每个新项目/模块中.Android Studio 目录中有一个包含模板的文件夹.寻找:

There is a way to add the library to every new project/module automatically. There is a folder with templates in the Android Studio directory. Look for:

..\Android Studio\plugins\android\lib\templates\gradle-projects\NewAndroidModule\root

在这个目录中有一个文件:

In this directory there is a file:

build.gradle.tfl

根据您的需要修改它.
示例:

Modify it according to your needs.
Example:

dependencies {
    <#if dependencyList?? >
    <#list dependencyList as dependency>
    compile '${dependency}'
    </#list>
    </#if>
    compile fileTree(dir: 'libs', include: ['*.jar'])
<#if WearprojectName?has_content && NumberOfEnabledFormFactors?has_content && NumberOfEnabledFormFactors gt 1 && Wearincluded>
    wearApp project(':${WearprojectName}')
    compile 'com.google.android.gms:play-services:+'
</#if>
<#if unitTestsSupported>
    testCompile 'junit:junit:${junitVersion}'
</#if>
    compile 'com.github.bumptech.glide:glide:3.7.0'
}

如您所见,最后添加了 Glide 库.

As you can see, the Glide library has been added at the end.

当这个文件被修改时,每一个新的Android Phone &表模块 将包含此库.

When this file is modified, every new Android Phone & Table module will have this library included.

当然,没有什么可以阻止您添加自己的模块或项目模板.

Of course there is nothing that prevents you from adding your own module or project template.

这篇关于在 Studio/SDK 的默认库列表中添加一个 android 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆