android-How to solve 'gradle build running stuck in android studio when using firebase crashlytics'
1. The purpose of this post
I would demo how to solve this error when using firebase crashlytics in android studio:
When we apply the firebase crashlytics in android studio and do a run, sometimes, the android studio is stuck in ‘gradle build running’ process, and it seems that it would never ends.
I have tried these methods:
- use the gradle parallel mode
- choose the offline mode
- clean the project and restart IntelliJ IDEA
- close the internet connection
It still not work.
2. Environments
The gradle version in gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
the build.gradle of project:
the build.gradle of app:
3. Debug and Solution
Build and run the app, it would stuck, click the build tab at the bottom of the IDEA window, you would see that it stuck in a process named ‘crashlyticsUploadDeobs…’, So let’s disable this task:
Open your app’s build.gradle, and add these lines at the end of your script:
According to the gradle lifecycle documents, it says:
Project evaluation You can receive a notification immediately before and after a project is evaluated. This can be used to do things like performing additional configuration once all the definitions in a build script have been applied, or for some custom logging or profiling.
Here we add a listener to gradle, and check if exists some tasks whose name starts with ‘crashlyticsUploadDeobs’, if it matches, then disable it.
Clean, build and rerun the app, problem solved.