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

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

问题描述

因此,首先,为了消除任何疑问,我知道如何向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库添加到我的项目中.为此,我必须转到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 & Table module都将包含此库.

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.

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

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