差异图书馆与放大器之间;图书馆项目和放大器;外部库 [英] Difference Between Library & Library Project & External Libraries

查看:218
本文介绍了差异图书馆与放大器之间;图书馆项目和放大器;外部库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio IDE中可以添加的的.jar 文件。您还可以添加那些整个项目的库项目。而且还有了Android库(从摇篮)添加为外部库

的.jar

图书馆计划

外部库

我得到的.jar文件是正义的。但后来怎么来的其他库(库项目)需要得到补充,有自己的(如gradle这个,资源,SRC等)的整个构建文件。进一步我的理解复杂的摇篮下载的人添加为外部库和那些有.jar文件和res文件夹。

你能解释一下为什么图书馆可以添加的.jar,整个项目或外部库?


解决方案

  

你能解释一下为什么图书馆可以添加的.jar,整个项目或外部库?


您有不同的可能性,因为你可以有不同的情况。通常情况下,库由其他团队建造,你不能决定它是如何分布的。


  • 您可以有一个自己的库或叉子本地。在这种情况下的你有code 并可以添加该库为模块

在此情况下,只需添加在模块/的build.gradle

 应用插件:'com.android.library

和增加的主要项目的依赖,如:

  {相关性
  编制项目(':模块)
}


  • 您可以使用行家依赖。在这种情况下,有人上传了Maven仓库的库。结果
    目前,它在我看来是最好的解决方案。

在这种情况下,只需添加在你的项目的依赖

  {相关性
  编译组:名称:版本
}

这依赖可能是一个 AAR 文件中,也有 JAR 文件。结果
您也可以在公共或私人的Maven发布自己的库。


  • 您可以在项目中添加一个 AAR文件

在这种情况下,定义你的平库:

  {库
    flatDir {
        迪尔斯'库'
    }
}

和添加依赖性:

  {相关性
   编译(名称:nameOfYou​​rAARFileWithoutExtension',分机:AAR)
 }


  • 您可以在您的项目中添加一个的jar文件

在这种情况下,通常你可以把所有的罐子在libs文件夹,并添加依赖关系:

  {相关性
    编译文件树(导演:'库',包括:['的* .jar'])
}

In the Android Studio IDE you can add a .jar file. You can also add entire projects that are 'Library Projects'. And there are also the Android libraries (from Gradle) added as External Libraries.

.jar

Library Project

External Library

I get that .jars are just that. But then how come other libraries (Library Projects) need to get added that have entire build files of their own (like gradle, res, src etc). And further complicating my understanding, the Gradle downloaded ones are added as 'External Libraries' and those have .jar files and a res folder.

Could you explain why libraries can be added as .jar, entire projects, or as external libraries?

解决方案

Could you explain why libraries can be added as .jar, entire projects, or as external libraries?

You have different possibilities, because you can have different cases. Often the library is built by other team and you can't decide how it is distributed.

  • You can have a own library or a fork locally. In this case you have the code and you can add this library as a module

In this case just add in the module/build.gradle:

apply plugin: 'com.android.library'

and add the dependency in the main project like:

dependencies{
  compile project(':module')
}

  • You can use a maven dependency. In this case someone uploaded the library in a maven repository.
    Currently it is the best solution in my opinion.

In this case just add a dependency in your project

dependencies{
  compile 'group:name:version'
}

This dependency can be a aar file, but also a jar file.
Also you can publish in a public or private maven your own libraries.

  • You can add an aar file in your project

In this case define your flat repository:

repositories {
    flatDir {
        dirs 'libs'
    }
}

and add the dependency:

dependencies {
   compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar')
 }

  • You can add a jar file in your project

In this case usually you can put all jars in the libs folder and add the dependency:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

这篇关于差异图书馆与放大器之间;图书馆项目和放大器;外部库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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