首页>Program>source

当我尝试使用Android Studio运行应用程序时,出现以下异常:

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

最新回答
  • 2021-1-11
    1 #

    我遇到了同样的问题,经过几个小时的研究,我找到了解决问题的解决方案。

    您应该修复 build.gradle

    android {
        compileSdkVersion ..
        buildToolsVersion '...'
        defaultConfig {
           ...
           targetSdkVersion ..
           multiDexEnabled true  // this line will solve this problem
       }
    }
    

    If the number of method references in your app exceeds the 65K limit, your app may fail to compile.

    有关如何执行此操作的信息,请参阅使用Android Studio 2.0 Preview 4选择性地将API编译到可执行文件和使用超过65K的方法构建应用程序

  • 2021-1-11
    2 #

    我突然遇到了这个问题并添加了 multiDexEnabled true 没有帮助,而且清理和重建也没有帮助。

    所以为我解决的唯一一件事就是删除该文件:

    YOUR_APP_NAME\app\build\intermediates

    并运行该应用程序,它便可以正常工作。

  • 2021-1-11
    3 #

    修改模块级build.gradle文件

    android {
        ...
        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
    

    }

    添加依赖项 编译'com.android.support:multidex:1.0.0'

    在清单中添加MultiDexApplication类

    <manifest ...>
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
    

    http://developer.android.com/studio/build/multidex.html

  • 2021-1-11
    4 #

    对我来说,关闭所有其他Android Studio即可解决问题。

    出现错误时,我开设了3个android工作室,关闭2个工作室后,我没有任何错误。

    无需添加与multiDex相关的任何代码!

    似乎存在与jvm相关的内存问题。

  • 2021-1-11
    5 #

    只需解决此问题.就我而言,重建项目对我有帮助。 因此,尝试重建您的项目。

  • c#什么时候应该使用列表,什么时候应该使用arraylist?
  • c#:静态和实例方法同名?