Since the first Unity 2017.3.0f3 and with later patch versions we can not build our project for Android anymore. It requires Gradle and the issue is:
But the project compiles perfectly in the previous Unity 2017.2.1. I see 2 potential changes in Unity 2017.3 that could be causing the new behaviour:
I have tried everything by now. I have created my gradle.properties file in my .gradle user folder that looks like:
I can say Gradle is getting some of the information of this file and using it, like daemon and parallel settings, as you can see in the build log:
BUT, I think org.gradle.jvmargs is being overriden by the gradle call that Unity is generating. If I take a look to the call to java for launching the gradle process you can see the max memory is being set with 2g:
So as Unity is calling this process with this setting, it is impossible to me to increase the memory when gradle process starts and the project fails when Gradle comes to action. The only way I can build the game by now is exporting the project in Gradle and then use Android Studio to create the final APK. This is a big issue as many other developers would want to test some new features and would be nice to not need external tools like Android Studio to achieve it.
So, I would expect some kind of new Gradle option in Android playersettings for setting this amount of memory Unity is sending to the command, or Unity should remove the ā-Dorg.gradle.jvmargs=-Xmx2048mā from the command line for Gradle to be able to get this information from user gradle.properties.
This problem is also happening in Unity beta 2018.1.0b4.
You can export build as Gradle project and build apk with Java heap parameter
For debug build
java -classpath org.gradle.launcher.GradleMain -p ā-Dorg.gradle.jvmargs=-Xmx4096mā āassembleDebugā
For release build
java -classpath org.gradle.launcher.GradleMain -p ā-Dorg.gradle.jvmargs=-Xmx4096mā āassembleReleaseā
Gradle launcher could be found at:
\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-.jar
Built apk will output to
\build\outputs\apk\debug
\build\outputs\apk\release
If you build with obb, the obb file will be exported at Gardle project root
Iām having this problem. Iāve tried exporting and running the above command. But it just spits out an error:
Error: Could not find or load main class assembleRelease