Android深入

android-studio_gradle编译加速

2017-10-26  本文已影响0人  22a5d2ee8385
gradle.properties
-----------------------------------------------------------------------------------------------------------------------------------------------
# 开启单独的Gradle守护进程
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx1208m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true

# 使用gradle.cache
org.gradle.caching = true
-----------------------------------------------------------------------------------------------------------------------------------------------
build.gradle(progect)
-----------------------------------------------------------------------------------------------------------------------------------------------
allprojects {
    gradle.taskGraph.whenReady {
        tasks.each { task ->
            if (task.name.contains("Test")
                    || task.name.contains("lint")
                    || task.name.equals("clean")
                    || task.name.contains("Aidl")
                    || task.name.contains("mockableAndroidJar")
                    || task.name.contains("UnitTest")
                    || task.name.contains("AndroidTest")
                    || task.name.contains("Ndk")
                    || task.name.contains("Jni")) {
                task.enabled = false
            }
        }
    }
}
-----------------------------------------------------------------------------------------------------------------------------------------------
build.gradle(model)
-----------------------------------------------------------------------------------------------------------------------------------------------
buildTypes {
        debug {
            signingConfig signingConfigs.debug   // 编译加速
            ext.alwaysUpdateBuildId = false  // 编译加速
            buildConfigField "long", "BUILD_TIMESTAMP", "000000000"  // 编译加速
        }
    }

    if (project.hasProperty("devBuild")) {  // 编译加速
        aaptOptions.cruncherEnabled = false  // 编译加速
    }

    dexOptions {          // 编译加速
        incremental true  // 编译加速
    }

    flavorDimensions "default"  // 编译加速
    productFlavors {  // 编译加速
        development {  // 编译加速
            minSdkVersion 21  // 编译加速
            dimension "default"  // 编译加速
            resConfigs("en", "xxhdpi")  // 编译加速
        }
        production {  // 编译加速
            dimension "default"  // 编译加速
        }
    }
-----------------------------------------------------------------------------------------------------------------------------------------------
上一篇下一篇

猜你喜欢

热点阅读