android gradle 3.0 学习笔记

Android gradle 3.0带来了编译速度的大幅优化,api也做了大幅调整

image.png

android gradle 3.0 需要Gradle版本 >= 4.1

buildscript {
    repositories {
        ...
        // You need to add the following repository to download the
        // new plugin.
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
    }
}

变化

  1. 引用library时会自动引用对应的flavor,比如app的 debug variant 自动依赖 library的 debug variant。
  2. 引入flavor dimensions,不同flavor dimensions的配置可以互相覆盖
  3. dependency compile,provided改成 api, implementation, compileOnly, runtimeOnly
New Configuration Deprecated configuration Note
implementation compile 依赖是内部实现,依赖改变时,只会编译当前模块
api compile 依赖是会导出为api,依赖改变时,所有依赖它的外部模块都要重新编译
compileOnly provided
runtimeOnly apk

4.library project 中的本地jar包,不再包含在aar中,而是通过transitive dependencies由app模块依赖
5.默认使用aapt2

  1. androidTestUtil 用来在instrumentation test运行之前安装apk,比如testbutler
dependencies {
  androidTestUtil 'com.linkedin.testbutler:test-butler-app:1.3.0@apk'
  ...
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容