Android Studio: Unexpected top level exception (finished with non-zero exit value 2..)

匿名 (未验证) 提交于 2019-12-03 01:23:02

问题:

When i'm trying to debug my android app i'm getting the following error message:

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 '/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

The error first appeared on adding a new dependency. This is my gradle file

compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.android.support:design:23.0.1' compile 'com.android.support:recyclerview-v7:23.0.1' compile 'com.google.dagger:dagger:2.0.1' apt 'com.google.dagger:dagger-compiler:2.0.1' provided 'javax.annotation:jsr250-api:1.0'  compile 'com.jakewharton:butterknife:7.0.1' compile 'de.greenrobot:eventbus:2.4.0' // Icepick compile 'frankiesardo:icepick:3.1.0' provided 'frankiesardo:icepick-processor:3.1.0' // Mosby compile 'com.hannesdorfmann.mosby:mvp:2.0.0' compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.1' apt 'com.hannesdorfmann.parcelableplease:processor:1.0.1'  compile 'com.ogaclejapan.smarttablayout:library:1.4.2@aar' compile 'com.ogaclejapan.smarttablayout:utils-v4:1.4.2@aar' compile 'com.ogaclejapan.smarttablayout:utils-v13:1.4.2@aar'

The error appears when i'm trying to use the smarttablayout. Using the gradle 1.4 Version. Does anybody know what is wrong?

回答1:

Just had the issue yesterday. I fixed it by manually removing the build/ and app/build/ folders, and by building the project again.

But it also might come from something else like your app reaching the 65k methods limit (in what case "Configuring Your App for Multidex with Gradle" will fix your issue). So you will need to provide the full Graddle log for us to be able to check more in detail what the issue could be.



回答2:

I had the same issue, solved it by doing the following

In the app build gradle file, inside android: add in defaultConfig:

multiDexEnabled true

and add this in the android:

dexOptions {     javaMaxHeapSize "4g" }

Ref: https://stackoverflow.com/a/25006428/2069407



回答3:

At my case change buildToolsVersion from "24" to "23.0.2", solve the problem especially if you're using old Android Studio less than version 2



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!