问题:org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0

本文总结了Android项目开发中常见的编译错误,包括资源找不到、jar包冲突及内存不足等问题,并提供了具体的解决方法。

  在用as开发项目的过程中,我碰到了这个错误,在网上找到了如下的解决方法,做下总结:


  • 被编译的代码或资源有问题( finished with non-zero exit value 1):

出现这种编译异常表现是exit value 1,一般会给出错误提示,所以很容易排查。这种错误很常见,错误提示有时候是在日志中明显的给出来了,如下示例所示:

     
1
2
3
4
5
6
7
8
     
:app:processDebugManifest
:app:processDebugResources
\app\src\main\res\layout\activity_welcome.xml
Error:(42, 26) No resource found that matches the given name (at 'src' with value '@drawable/welcome_03').
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide
.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process 'command 'D:\android-sdk-windows\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1

上面错误提示找不到welcome_03这个drawable资源。有时候没有明显的提示,如下面这种错误:

     
1
2
3
4
5
6
7
     
:app:transformClassesWithMultidexlistForDebug UP-TO-DATE
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

上面这种错误没有给出很显示的提示,但是可以知道是在执行Error:Execution failed for task ':app:transformClassesWithDexForDebug'这一步出错了,至少缩小了错误的排查范围,这个时候就需要经验来判断了,自己之前改过什么,自己回想一下。有时候往上面看错误日志,也会发现有很明显的错误提示。



  • jar包冲突(finished with non-zero exit value 2):
  • 编译的dex 内存不够
  
android {
// ...
dexOptions {
javaMaxHeapSize "4g"
}
}


主要表现为编译后出现finished with non-zero exit value 2错误,原因是jar包冲突,导致的原因可能是在dependencies中使用compile files()导入一次jar包,然后有其它jar的引入方式使用compile’com.xxx’方式,正好又引用了这个jar包,所以导致了重复引用jar包的冲突。最常见的是support-v4包的重复引用。具体报错如下所示:

     
1
2
3
4
     
Error:Execution failed for task ':task:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process 'command 'C:\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2




  • 编译的代码过多导致内存不足(finished with non-zero exit value 3):
    主要表现为编译后出现finished with non-zero exit value 3错误,原因是因为编译的java代码过多,通常是方法数超过65535后使用了分包的机制,gradle在编译的时候由于编译的内存需要不能满足而导致错误。具体报错内容如下所示:
     
1
2
3
4
5
6
     
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process 'command 'C:\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 3

解决方案是在gradle文件中的Android代码块内增加如下内容即可解决:

     
1
2
3
4
5
6
7
8
     
android {
// ...
dexOptions {
javaMaxHeapSize "4g"
}
}

或者修改android studio的安装目录下的bin目录中的studio.vmoptions文件中的XmsXmx两项,将其值改大,如下所示:

     
1
2
     
-Xms256m
-Xmx1280m

出现这种情况的原因是因为项目太大,编译需要更多的内存。

> Task :app:preBuild UP-TO-DATE > Task :app:preDebugBuild UP-TO-DATE > Task :app:javaPreCompileDebug UP-TO-DATE > Task :app:checkDebugAarMetadata UP-TO-DATE > Task :app:processDebugNavigationResources UP-TO-DATE > Task :app:compileDebugNavigationResources UP-TO-DATE > Task :app:generateDebugResValues UP-TO-DATE > Task :app:mapDebugSourceSetPaths UP-TO-DATE > Task :app:generateDebugResources UP-TO-DATE > Task :app:mergeDebugResources UP-TO-DATE > Task :app:packageDebugResources UP-TO-DATE > Task :app:parseDebugLocalResources UP-TO-DATE > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE > Task :app:extractDeepLinksDebug UP-TO-DATE > Task :app:processDebugMainManifest UP-TO-DATE > Task :app:processDebugManifest UP-TO-DATE > Task :app:processDebugManifestForPackage UP-TO-DATE > Task :app:processDebugResources UP-TO-DATE > Task :app:compileDebugJavaWithJavac UP-TO-DATE > Task :app:bundleDebugClassesToRuntimeJar UP-TO-DATE > Task :app:bundleDebugClassesToCompileJar UP-TO-DATE > Task :app:preDebugUnitTestBuild UP-TO-DATE > Task :app:javaPreCompileDebugUnitTest UP-TO-DATE > Task :app:compileDebugUnitTestJavaWithJavac UP-TO-DATE > Task :app:processDebugJavaRes NO-SOURCE > Task :app:processDebugUnitTestJavaRes NO-SOURCE Could not write standard input to Gradle Test Executor 2. java.io.IOException: 管道正在被关闭。 at java.base/java.io.FileOutputStream.writeBytes(Native Method) at java.base/java.io.FileOutputStream.implWriteBytes(Unknown Source) at java.base/java.io.FileOutputStream.write(Unknown Source) at java.base/java.io.BufferedOutputStream.flushBuffer(Unknown Source) at java.base/java.io.BufferedOutputStream.implFlush(Unknown Source) at java.base/java.io.BufferedOutputStream.flush(Unknown Source) at org.gradle.process.internal.streams.ExecOutputHandleRunner.writeBuffer(ExecOutputHandleRunner.java:98) at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:85) at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:64) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64) at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:48) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) > Task :app:testDebugUnitTest FAILED ����: �Ҳ������޷��������� JDK\bin;D:\Java ԭ��: java.lang.ClassNotFoundException: JDK\bin;D:\Java [Incubating] Problems report is available at: file:///D:/Android%20TEST/build/reports/problems/problems-report.html FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:testDebugUnitTest'. > Process 'Gradle Test Executor 2' finished with non-zero exit value 1 * 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. > Get more help at https://help.gradle.org. Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.13/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. BUILD FAILED in 663ms 22 actionable tasks: 1 executed, 21 up-to-date 13:52:47: Execution finished 'testDebugUnitTest'.
最新发布
10-24
D:\Software\DevelopmentSoftware\tomcat-green-8.0.52\bin\catalina.bat run [2025-05-31 06:00:52,496] 工件 testhzjcjep2022:war exploded: 正在等待服务器连接以启动工件部署… set JAVA_HOME successfully set CLASSPATH successfully Could not locate D:\Software\DevelopmentSoftware\jdk1.7.0_51\jre\lib\tools.jar. Unexpected results may occur. =============================================================================== JAVA Environment... JAVA: D:\Software\DevelopmentSoftware\jdk1.7.0_51\jre\bin\java JAVA_HOME: D:\Software\DevelopmentSoftware\jdk1.7.0_51\jre CLASSPATH: D:\Software\DevelopmentSoftware\jdk1.7.0_51\jre\lib;D:\Software\DevelopmentSoftware\jdk1.7.0_51\jre\lib\tools.jar =============================================================================== Using CATALINA_BASE: "C:\Users\62403\AppData\Local\JetBrains\IntelliJIdea2023.2\tomcat\04732bd9-e09d-4c2c-b30f-f51153146ebb" Using CATALINA_HOME: "D:\Software\DevelopmentSoftware\tomcat-green-8.0.52" Using CATALINA_TMPDIR: "D:\Software\DevelopmentSoftware\tomcat-green-8.0.52\temp" Using JRE_HOME: "D:\Software\DevelopmentSoftware\jdk1.7.0_51\jre" Using CLASSPATH: "D:\Software\DevelopmentSoftware\tomcat-green-8.0.52\bin\bootstrap.jar;D:\Software\DevelopmentSoftware\tomcat-green-8.0.52\bin\tomcat-juli.jar" 已连接到地址为 ''127.0.0.1:10059',传输: '套接字'' 的目标虚拟机 31-May-2025 18:00:53.356 警告 [main] org.apache.catalina.startup.SetAllPropertiesRule.begin [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'maxSpareThreads' to '100' did not find a matching property. 31-May-2025 18:00:53.391 警告 [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin [SetPropertiesRule]{Server/Service/Engine/Host} Setting property 'xmlValidation' to 'false' did not find a matching property. 31-May-2025 18:00:53.391 警告 [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin [SetPropertiesRule]{Server/Service/Engine/Host} Setting property 'xmlNamespaceAware' to 'false' did not find a matching property. 31-May-2025 18:00:53.408 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.52 31-May-2025 18:00:53.411 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Apr 28 2018 16:24:29 UTC 31-May-2025 18:00:53.413 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.52.0 31-May-2025 18:00:53.413 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 8 31-May-2025 18:00:53.424 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.2 31-May-2025 18:00:53.424 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: x86 31-May-2025 18:00:53.424 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: D:\Software\DevelopmentSoftware\jdk1.7.0_51\jre 31-May-2025 18:00:53.424 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.7.0_51-b13 31-May-2025 18:00:53.424 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation 31-May-2025 18:00:53.424 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: C:\Users\62403\AppData\Local\JetBrains\IntelliJIdea2023.2\tomcat\04732bd9-e09d-4c2c-b30f-f51153146ebb 31-May-2025 18:00:53.424 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: D:\Software\DevelopmentSoftware\tomcat-green-8.0.52 31-May-2025 18:00:53.427 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\62403\AppData\Local\JetBrains\IntelliJIdea2023.2\tomcat\04732bd9-e09d-4c2c-b30f-f51153146ebb\conf\logging.properties 31-May-2025 18:00:53.427 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 31-May-2025 18:00:53.427 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:10059,suspend=y,server=n 31-May-2025 18:00:53.428 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -javaagent:C:\Users\62403\AppData\Local\JetBrains\IntelliJIdea2023.2\captureAgent\debugger-agent.jar 31-May-2025 18:00:53.428 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote= 31-May-2025 18:00:53.428 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=10991 31-May-2025 18:00:53.429 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false 31-May-2025 18:00:53.429 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\62403\AppData\Local\JetBrains\IntelliJIdea2023.2\tomcat\04732bd9-e09d-4c2c-b30f-f51153146ebb\jmxremote.password 31-May-2025 18:00:53.429 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\62403\AppData\Local\JetBrains\IntelliJIdea2023.2\tomcat\04732bd9-e09d-4c2c-b30f-f51153146ebb\jmxremote.access 31-May-2025 18:00:53.429 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1 31-May-2025 18:00:53.429 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048 31-May-2025 18:00:53.430 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 31-May-2025 18:00:53.430 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs= 31-May-2025 18:00:53.430 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\62403\AppData\Local\JetBrains\IntelliJIdea2023.2\tomcat\04732bd9-e09d-4c2c-b30f-f51153146ebb 31-May-2025 18:00:53.430 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=D:\Software\DevelopmentSoftware\tomcat-green-8.0.52 31-May-2025 18:00:53.430 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=D:\Software\DevelopmentSoftware\tomcat-green-8.0.52\temp 31-May-2025 18:00:53.430 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Software\DevelopmentSoftware\jdk1.7.0_51\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Software\DevelopmentSoftware\VMware Workstation\bin\;C:\Program Files\Common Files\Siemens\Automation\Simatic OAM\bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\TortoiseSVN\bin;D:\Software\DevelopmentSoftware\nodejs\;D:\Software\DevelopmentSoftware\Redis\Redis-x64-3.2.100;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;D:\Software\DevelopmentSoftware\mysql8.0.34\bin;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files\Java\jdk1.8.0_152\bin;C:\Program Files\Java\jdk1.8.0_152\jre\bin;D:\Software\DevelopmentSoftware\NetSarang\Xshell 8\;D:\Software\DevelopmentSoftware\NetSarang\Xftp 8\;C:\Program Files\dotnet\;D:\Software\DevelopmentSoftware\微信web开发者工具\dll;F:\Cloud Server\Soft\VisualSVN Server\bin;D:\Software\DevelopmentSoftware\Python\Python312\Scripts\;D:\Software\DevelopmentSoftware\Python\Python312\;C:\Users\62403\AppData\Local\Microsoft\WindowsApps;;D:\Software\DevelopmentSoftware\Microsoft VS Code\bin;C:\Users\62403\AppData\Roaming\npm;. 31-May-2025 18:00:53.540 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8098"] 31-May-2025 18:00:53.562 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 31-May-2025 18:00:53.565 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-5629"] 31-May-2025 18:00:53.567 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 31-May-2025 18:00:53.568 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 445 ms 31-May-2025 18:00:53.602 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina 31-May-2025 18:00:53.602 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.52 31-May-2025 18:00:53.619 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8098"] 31-May-2025 18:00:53.638 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-5629"] 31-May-2025 18:00:53.641 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 73 ms 已连接到服务器 [2025-05-31 06:00:53,856] 工件 testhzjcjep2022:war exploded: 正在部署工件,请稍候… 31-May-2025 18:00:57.937 警告 [RMI TCP Connection(4)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJspConfig Failed to process TLD with path [/WEB-INF/struts-template.tld] and URI [/WEB-INF/struts-template.tld]. The specified path does not exist. 31-May-2025 18:00:58.134 信息 [RMI TCP Connection(4)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. Server start lineuser clear! [2025-05-31 06:01:02,106] 工件 testhzjcjep2022:war exploded: 工件已成功部署 [2025-05-31 06:01:02,106] 工件 testhzjcjep2022:war exploded: 部署已花费 8,250 毫秒 31-May-2025 18:01:03.623 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory D:\Software\DevelopmentSoftware\tomcat-green-8.0.52\webapps\manager 31-May-2025 18:01:03.666 信息 [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 31-May-2025 18:01:03.672 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory D:\Software\DevelopmentSoftware\tomcat-green-8.0.52\webapps\manager has finished in 49 ms
06-01
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值