简体   繁体   English

在发布版本完成之前,Gradle 4.1会进行崩溃上传

[英]Gradle 4.1 does crashlytics upload before release build finishes

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. 将我们的开发和构建环境从Android Studio 2升级到3(目前在gradle 4.1上),我们在运行Crashlytics APK分发上载任务时遇到了一个奇怪的问题。 It tries to upload the APK way too early. 它试图过早上传APK方式。 At around the 60s mark in our build it fails with: 在我们的构建中大约60年代标记它失败了:

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
:appname:crashlyticsUploadDistributionFlavournameRelease FAILED

(Normal build times are around 7 mins.) I did double check the output paths of the APK and it all seems correct. (正常构建时间约为7分钟。)我仔细检查了APK的输出路径,这一切似乎都是正确的。

Interestingly when remoting on to the Windows build machine, and running the build command that our CI runs manually: 有趣的是,当远程访问Windows构建计算机并运行我们的CI手动运行的构建命令时:

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. 最后,我已经将不良行为追溯到运行构建命令之前运行的git clean 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. 如果项目中有多个模块,则使用--max-workers=1的解决方案将大大减慢构建时间。

You can solve this problem by setting the order to the crashlyticsUploadDistribution task manually in your build.gradle file: 您可以通过在build.gradle文件中手动设置crashlyticsUploadDistribution任务的顺序来解决此问题:

tasks.whenTaskAdded { task ->
    if (task.name == "crashlyticsUploadDistributionDebug") {
        task.dependsOn assembleDebug
    }
    if (task.name == "crashlyticsUploadDistributionRelease") {
        task.dependsOn assembleRelease
    }
}

afterEvaluate {
    crashlyticsUploadDistributionDebug.dependsOn assembleDebug
    crashlyticsUploadDistributionRelease.dependsOn assembleRelease
}

I suspect the ordering of the gradle tasks might be off. 我怀疑gradle任务的顺序可能会关闭。 Crashlytics seems to try and upload the APK before waiting for the build to actually complete. Crashlytics似乎试图在等待构建实际完成之前上传APK。

Adding the gradle comandline flag: --max-workers=1 made the builds pass consistently. 添加gradle comandline标志: --max-workers=1 max --max-workers=1使构建一致地传递。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM