• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

vanniktech/gradle-android-apk-size-plugin: Gradle plugin that generates CSV file ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

vanniktech/gradle-android-apk-size-plugin

开源软件地址(OpenSource Url):

https://github.com/vanniktech/gradle-android-apk-size-plugin

开源编程语言(OpenSource Language):

Groovy 55.1%

开源软件介绍(OpenSource Introduction):

gradle-android-apk-size-plugin

Gradle plugin that generates CSV files with apk size per output and variant of apk. The files can be found here <projectbuildDir>/outputs/apksize/. In addition while building it'll also print out the size of the apk.

Starting from version 0.3.0 the plugin can also be applied to Android library projects and hence it'll print out the aar size instead of the apk size.

This plugin creates a task per output file, per variant, and configures each task to run after the variant's assemble task. This means that if the assemble task does not run, no apk size will be reported.

Works with the latest stable Gradle Android Tools version 3.0.1.

Set up

app/build.gradle

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath "com.vanniktech:gradle-android-apk-size-plugin:0.4.0"
  }
}

apply plugin: "com.vanniktech.android.apk.size"

Information: This plugin is also available on Gradle plugins

Snapshot

buildscript {
  repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
  }
  dependencies {
    classpath "com.vanniktech:gradle-android-apk-size-plugin:0.5.0-SNAPSHOT"
  }
}

apply plugin: "com.vanniktech.android.apk.size"

Sample output

> ./gradlew assembleDebug

...buildspam...
:app:packageDebug
:app:zipalignDebug
:app:assembleDebug
Total APK Size in my-app-debug in bytes: 3231060

BUILD SUCCESSFUL

Total time: 33.017 secs

Detailed output

<projectbuildDir>/outputs/apksize/debug.csv
<projectbuildDir>/outputs/apksize/release.csv

Those CSV files can for instance be used to configure the Jenkins Plot Plugin, to see the apk size for each build in a graph.

Configuration

Apksize is configurable via a Gradle extension (shown with default values) in app/build.gradle:

apkSize {
  maxApkSize = 5800000
  teamcity = true
}

Configurable flags:

  • maxApkSize: Set the max APK size in Kb. Greater than specified size will fail the build. Default is -1.
  • teamcity : Enable teamcity statistics ready log output. Default is true if run on teamcity otherwise default is false.

Teamcity

This will print logs in the form of

##teamcity[buildStatisticValue key='ApkSize_${apk.name}_B' value='{size in bytes}']
##teamcity[buildStatisticValue key='ApkSize_${apk.name}_MB' value='{size in megabytes}']

see https://confluence.jetbrains.com/display/TCD10/Build+Script+Interaction+with+TeamCity for an in depth explanation how it works

License

Copyright (C) 2015 Vanniktech - Niklas Baudy

Licensed under the Apache License, Version 2.0




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap