zoukankan      html  css  js  c++  java
  • AndroidStudio3.x中api、compile和implementation的区别

    首先在AndroidStudio3.x中compile已经过时

    由implementation和api来代替

    其次compile与api完全等同 3.x中可以完全将compile换成api

    mplementation与api的区别

    implementation编译的依赖只作用于当前的module。即app module依赖了other module,

    other module中使用implementation编译的三方库(如glide)只对other module起作用,

    app module中无法使用该三方库(glide);

    如果other module 使用implementation依赖了base module,则APP module中无法使用base module。

    举个示例:

    我们把其它module中的对com.alibaba.fastjson:1.2.6引用改成implementation

     那么我们在app module里面是无法使用的 因为implementation 只对当前module生效

    便会提示:错误: 程序包com.alibaba.fastjson不存在

     

    总体介绍

    compile(api)
    这种是我们最常用的方式,使用该方式依赖的库将会参与编译和打包。

    provided(compileOnly)
    只在编译时有效,不会参与打包,可以在自己的moudle中使用该方式依赖。比如com.android.support,gson这些使用者常用的库,避免冲突。

    apk(runtimeOnly)
    只在生成apk的时候参与打包,编译时不会参与,很少用。

    testCompile(testImplementation)
    testCompile 只在单元测试代码的编译以及最终打包测试apk时有效。

    debugCompile(debugImplementation)
    debugCompile 只在debug模式的编译和最终的debug apk打包时有效。

    releaseCompile(releaseImplementation)
    releaseCompile 仅仅针对Release模式的编译和最终的Release apk打包。

  • 相关阅读:
    MVC、MVP、MVVM架构模式
    JavaScript中的跨域详解(二)
    JavaScript中的跨域详解(一)
    RESTful基础知识
    Date类
    数据的相对比较
    递归应用
    浏览器在一次 HTTP 请求中,需要传输一个 4097 字节的文本数据给服务端,可以采用那些方式?
    【04】图解JSON
    【08】css sprite是什么,有什么优缺点
  • 原文地址:https://www.cnblogs.com/vic-tory/p/12411422.html
Copyright © 2011-2022 走看看