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

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  在用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

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

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
### 解决方案分析 Gradle 版本 `8.7` 出现 `ModuleVersionResolveException: Could not resolve` 错误通常是因为以下几个原因: 1. **网络问题**:Gradle 无法访问远程仓库来下载所需的依赖项。 2. **配置错误**:项目的 `build.gradle` 或 `settings.gradle` 文件中的配置不正确,可能导致 Gradle 无法解析模块版本。 3. **兼容性问题**:使用的 Android Gradle 插件(AGP)版本可能与当前的 Gradle 版本不兼容。 以下是针对该问题的具体解决方案: --- #### 1. 配置国内 Maven 镜像源 由于国外的 Maven 中央仓库可能存在访问受限的情况,可以尝试切换到国内的镜像源。例如阿里云或腾讯云提供的镜像服务。 在 `build.gradle` 文件中添加如下内容: ```groovy buildscript { repositories { mavenCentral() maven { url "https://maven.aliyun.com/repository/public/" } google() } } allprojects { repositories { mavenCentral() maven { url "https://maven.aliyun.com/repository/public/" } google() } } ``` 此方法通过替换默认的 Maven Central 和 Google 仓库 URL 来加速依赖项的下载[^5]。 --- #### 2. 手动下载并指定 Gradle 安装路径 如果自动同步失败,可以通过手动方式下载对应版本的 Gradle 并指定其安装路径。 - 下载地址:[腾讯云 Gradle 镜像](https://mirrors.cloud.tencent.com/gradle/) - 将下载好的 `.zip` 文件放置到本地目录,例如 `C:\Users\<用户名>\.gradle\wrapper\dists\gradle-8.7-all`. - 删除旧的缓存文件夹(如 `6nifqtx7604sqp1q6g8wikw7p`),并将新的 `.zip` 文件粘贴至目标位置[^4]. 重启 IDE 后再次尝试同步项目。 --- #### 3. 检查 AGP 与 Gradle 的兼容性 根据官方文档,不同版本的 AGP 对应特定范围内的 Gradle 版本。以下是一些常见组合: | AGP Version | Required Gradle Version | |-------------|--------------------------| | 8.4 | 8.0 - 9.0 | 因此,在使用 AGP `8.4.0` 时,推荐将 Gradle 升级到至少 `8.0` 而非强制绑定到 `8.7`. 如果确实需要使用 `8.7`, 则需确认两者完全兼容[^3]. 修改 `gradle/wrapper/gradle-wrapper.properties` 文件中的分布 URL: ```properties distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip ``` --- #### 4. 清理缓存并重试 有时 Gradle 缓存可能会导致冲突,建议清理后再执行构建操作: 运行以下命令清除缓存: ```bash ./gradlew clean --refresh-dependencies ``` 或者直接删除整个 `.gradle/caches` 文件夹后重新启动项目[^1]. --- #### 5. 修改 JDK 版本适配 部分情况下,JDK 版本也可能影响 Gradle 构建过程。确保所用 JDK 至少为 Java 17 (适用于 Gradle 8.x),并在 `build.gradle` 中显式声明编译选项: ```groovy android { compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } } ``` 同时更新系统的 JAVA_HOME 环境变量指向正确的 JDK 安装路径[^3]. --- ### 总结 综合以上措施可有效解决因 Gradle 版本引起的 `ModuleVersionResolveException` 报错现象。优先考虑调整 Maven 仓库配置以及验证工具链之间的相互匹配关系。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值