com.android.build.transform.api.TransformExceptionbuild、android、com、TransformException

2023-09-12 09:13:45 作者:我爹她闺女可萌了^ō^

我试图整合谷歌登录,在我的应用程序,我添加了这些库:

 编译com.google.android.gms:玩-服务身份:8.1.0
编译com.google.android.gms:玩-服务加:8.1.0
 

也将它添加到项目构建摇篮:

 类路径com.google.gms:谷歌服务:1.4.0-β3
 

aslo加入插件,应用程序构建摇篮:

 应用插件:com.google.gms.google,服务
 
谷歌发布Android 8.1首个开发者预览版 内存效率暴增

再加入所需的权限 但是当我尝试运行我的应用程序,recived此错误:

 错误:未能执行任务:应用程序:transformClassesWithDexForDebug。
    com.android.build.transform.api.TransformException:com.android.ide.common.process.ProcessException:
    org.gradle.process.internal.ExecException:进程命令C:\ Program Files文件\的Java \ jdk1.8.0 \ BIN \ java.exe的''非零退出值2结束
 

解决方案

尝试添加 multiDexEnabled真正您的应用程序的 build.gradle 文件。

  defaultConfig {
    multiDexEnabled真
}
 

编辑:

尝试史蒂夫的回答第一。在情况下,它经常发生或第一步并没有帮助 multiDexEnabled 可能的帮助。对于那些谁爱更深层次的挖掘这里是几个类似的问题(有更多的答案):

:应用程序:dexDebug ExecException完成非零退出值2 错误:执行失败的任务:应用程序:dexDebug。 com.android.ide.common.process.ProcessException

i am trying to integrate google sign in , in my app,i added these libraries:

compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-plus:8.1.0'

also add this to project build gradle:

classpath 'com.google.gms:google-services:1.4.0-beta3'

aslo add plugin to app build gradle:

apply plugin: 'com.google.gms.google-services'

then add required permissions but when i try to run my app , recived this error:

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

解决方案

Try adding multiDexEnabled true to your app build.gradle file.

 defaultConfig {
    multiDexEnabled true
}

EDIT:

Try Steve's answer first. In case it happens frequently or first step didn't help multiDexEnabled might help. For those who love to dig deeper here is couple similar issues (with more answers):

:app:dexDebug ExecException finished with non-zero exit value 2 Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException