编译,提供APK - Android的依赖范围 [英] Compile, Provided, APK - Android dependency scope

查看:322
本文介绍了编译,提供APK - Android的依赖范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而在添加新的依赖于Android项目特别是在 Android的工作室依赖有三种作用域选项编译/提供/ APK。

While adding new dependencies to android project especially in Android Studio in Dependencies there are three scope options Compile/Provided/APK.

什么是选择每个人的影响,我们什么时候使用它们呢?再说什么名字说。

What are the effects of choosing each one, when should we use them ? Besides what the name says.

编辑:

妥善处理规定和包范围做他们应该做的。 '提供'和'包'不能与Android库使用,将产生一个错误。这是从<一个href="http://tools.android.com/tech-docs/new-build-system">http://tools.android.com/tech-docs/new-build-system

"Properly handle 'provided' and 'package' scopes to do what they should be doing. 'provided' and 'package' cannot be used with Android Libraries, and will generate an error" .. this is from http://tools.android.com/tech-docs/new-build-system

推荐答案

  • 提供 - 编译时只能依赖
  • - 包时只依赖
  • 编译 - 编译时和包时依赖

  • provided - compile-time only dependency
  • package - package-time only dependency
  • compile - compile-time and package-time dependency
  • 提供通常用于注释处理基础库。通常这些库分居两神器 - 说文解字注和编译器。 编译是提供的依赖,因为你并不需要使用它的应用程序,只为汇编;和注释是编译相关性 - 它是用在应用code,因此编译。或者产生code可能需要额外的依赖,而你的应用程序可能不会。例如。匕首依赖配置:

    provided is commonly used for annotation processing based libraries. Usually these libraries are separated in two artifacts - "annotation" and "compiler". "compiler" is provided dependency because you do not need to use it in application, only for compilation; and "annotation" is compile dependency - it is used in application code and therefore compiles. Or generated code may require additional dependencies while your application may not. E.g. dagger dependencies configuration:

    compile 'com.squareup.dagger:dagger:1.2.2'
    provided 'com.squareup.dagger:dagger-compiler:1.2.2'
    

    这篇关于编译,提供APK - Android的依赖范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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