I am trying to build and run a mobile app project for Android, on my Mac OS machine (Apple Silicon). I keep getting an error related to gradle and java… please see the message below:
hi @IGuscin :
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
FAILURE: Build failed with an exception.
What went wrong:
Could not dispatch a message to the daemon.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
I tried many other things alongside this, which I would recommend to anyone else trying to debug this issue:
Try to build an empty unity project and see if that passes or fails
Check logs in ~/User/Library/Logs/Unity/Editor.log whilst building the project and try to pick up clues from the logs as to what the issue could be.
Ensure Java is installed and recognised on machine by running in a terminal by running java --version , if you do not have a recognised version of java chances are you will need to set up the correct path with a sym link … I followed instructions on the top answer of this stack post: macos - Java/JDK for the Apple Silicon chips - Stack Overflow
Try uninstalling / reinstalling Unity, ensuring all the android add ons are included.
RESTART YOUR MACHINE.
Check for any filters or proxies that could be blocking communication to gradle daemons under System settings > Network > Filters & Proxies , and disable these temporarily whilst building your project.
if you install gradle from homebrew and run it in your terminal with options , gradle build
–stacktrace, you will get some clues as to what the issue is with gradle, for me it was “cannot send message to gradle daemon” along those lines (as people mention in this stack article gradle - Could not dispatch a message to the daemon - Stack Overflow) …
Installing Android Studio and building out your project in EXPORT mode and trying with the highest SDK could help - also reveal some issues in Android Studio build logs that could set you on the right path.
This was a bitch to resolve but hopefully you can try some of these things and something will point in the right direction if anyone else face this issue.