Closed jaredsburrows closed 7 years ago
That seems like a really good idea. 👍
If so it should be splitted though usually debug apk is much bigger than release.
@vanniktech I am trying to set a limit only for my release build, is this possible?
I don't think so. The release hasn't been made. You can try the snapshot though.
Sorry for the confusion. I mean in the snapshot version 0.4-SNAPSHOT, is there a way to only fail my build (assembleRelease) if the size of the release apk is too large, but not have any rules around sizes for my debug APK?
Oh no. There's only one size unfortunately.
would be cool if you could add that in. as, as you said, the release apk is usually smaller cause of proguard
Yeah. If you want you can create a PR for it. I don't have much time to work on this project at the moment.
I may attempt it, but I've never touched a gradle plugin. Got any suggestions for how to solve this?
You can look at the PR that did the initial implementation.
@athkalia Use gradle:
gradle.taskGraph.afterTask { task ->
if (gradle.taskGraph.hasTask("assembleRelease")) {
dexcount {
maxApkSize = 5800000
}
}
}
the task graph is always going to have an assembleRelease task right? regardless of which task is currently executing, assembleDebug or assembleRelease
@athkalia No and I didn't mean to use afterTask
.
Something like this:
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(":app:assembleRelease")) {
dexcount {
maxApkSize = 5800000
}
}
}
To set dexcount.maxApkSize = 5800000
, simply run:
gradlew :app:assembleRelease
Docs: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#configure-by-dag
thanks pal, I'll give it a go
cool pal, it works!! thanks a lot.
Btw it should be apkSize
instead of dexcount
@vanniktech It looks like we need to fix the README.md: https://github.com/vanniktech/gradle-android-apk-size-plugin#configuration.
I also noticed that in the console this appears btw
The current APK is 2853469 Kb, the current max is: 1 Kb.
It should have been bytes not Kb
@athkalia @vanniktech Should we create an issue for this?
Sure.
Question:
Can we add an integer such as "maxApkSize" in an extension in order to fail builds that go over a certain size?
Example:
This will help developers that are developing on their local machines not only make better decisions on the code that they write but the libraries they use.