升级到Android Studio 3.0 后有没有发现编译项目的速度提高了?
为什么会这样呢?是因为Stuido 3.0 中支持了 Gradle plugin 3.0, Gradle plugin 3.0 在 dependencise 块中为我们带了一下新的API:
compile
被api
所代替。provided
被compileOnly
代替apk
被runtimeOnly
代替- 引入了新的
implementation
我了更好的理解 Gradle plugin 3.0 所带来的性能提高,我们来和Gradle plugin 2.x对比进行分析一下:
Gradle plugin 2.x
假设有如下一种情景:
我们有一个工程Project, 包含一个App module 和 10个 Library module,其中他们的依赖关系如上图所示。
每一个module 里面仅有一个简单的class。
Library1:
public class Library1 {
public static String getString() {
return "Im,Library1 -> " + Library11.getString();
}
}
// Library1 依赖 Library11
dependencies {
....
compile project(':library11')
}
Library11
public class Library11 {
public static String getString() {
return "Im,Library11 -> " + Library111.getString();
}
}
// Library11 依赖 Library111
dependencies {
....
compile project(':library111')
}
Library111