在Jenkins上构建Android项目时,Gradle构建守护
2019-03-29 本文已影响0人
磐龍
前言
最近在windows10上,用docker搭建了centos7系统,并在系统内搭建jenkins用于android项目的自动编译,让测试人员、产品经理根据需要出包。
问题
执行./gradlew clean assembleRelease --s
命名后,编译一段时间后报错如下:
* Exception is:
19:36:01 org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
19:36:01 at org.gradle.launcher.daemon.client.DaemonClient.handleDaemonDisappearance(DaemonClient.java:238)
19:36:01 at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:214)
19:36:01 at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:178)
19:36:01 at org.gradle.launcher.daemon.client.SingleUseDaemonClient.execute(SingleUseDaemonClient.java:54)
19:36:01 at org.gradle.launcher.daemon.client.SingleUseDaemonClient.execute(SingleUseDaemonClient.java:36)
19:36:01 at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
19:36:01 at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
19:36:01 at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:285)
19:36:01 at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:258)
19:36:01 at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
19:36:01 at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
19:36:01 at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:251)
19:36:01 at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:185)
19:36:01 at org.gradle.launcher.Main.doAction(Main.java:36)
19:36:01 at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
19:36:01 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:36:01 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
19:36:01 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
19:36:01 at java.lang.reflect.Method.invoke(Method.java:498)
19:36:01 at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
19:36:01 at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
19:36:01 at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
19:36:01 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
19:36:01 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
19:36:01 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
19:36:01 at java.lang.reflect.Method.invoke(Method.java:498)
19:36:01 at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:31)
19:36:01 at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108)
19:36:01 at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
解法
将守护进程设置为false,在~/.gradle 目录下 gradle.properties 文件(如果没有则新建)
org.gradle.daemon=false
org.gradle.jvmargs=-XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8