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打包。

  • 相关阅读:
    RAID中的Stripe size对性能的影响?
    TCP segmentation offload
    传统网络配置命令与IP高级路由命令
    WebTrends Log Analyzer
    linux使用vi中文乱码的解决办法
    链接静态库的顺序问题
    tcpdump命令格式
    怎样取得文件行数
    Tcpdump命令的使用与示例——linux下的网络分析
    Linux系统面面观 PROC文件系统详细介绍
  • 原文地址:https://www.cnblogs.com/vic-tory/p/12411422.html
Copyright © 2011-2022 走看看