Home » Android » android – Gradle 4.1 does crashlytics upload before release build finishes

# android – Gradle 4.1 does crashlytics upload before release build finishes

Questions:

Upgrading our dev and build environment from Android studio 2 to 3 (currently on gradle 4.1) we are running into a strange problem when running the Crashlytics APK distribution upload task. It tries to upload the APK way too early. At around the 60s mark in our build it fails with:

Uploading D:\GitRunner\path\to\release\appname-flavour1name-release.apk to Crashlytics...
WARN - Crashlytics halted compilation because it can't find the specified file: D:\GitRunner\path\to\release\appname-flavour1name-release.apk


(Normal build times are around 7 mins.) I did double check the output paths of the APK and it all seems correct.

Interestingly when remoting on to the Windows build machine, and running the build command that our CI runs manually:

gradlew.bat assembleFlavour1NameRelease assembleFlavour2NameRelease appname:crashlyticsUploadDistributionFlavour1NameRelease reptile:crashlyticsUploadDistributionFlavour1NameRelease --stacktrace


it all works fine.

Eventually I have traced the bad behaviour down to the git clean that is run before the build command are run. Somehow this changes the behaviour enough to make the build pass or not.

I’ve faced the same issue. The solution with --max-workers=1 will dramatically slow down your build time if you have multiple modules in your project.

tasks.whenTaskAdded { task ->
}
}
}

afterEvaluate {

Adding the gradle comandline flag: --max-workers=1 made the builds pass consistently.