【发布时间】:2016-02-19 09:33:21
【问题描述】:
当我让应用程序使用许多库时。我通常遇到一个错误是UNEXPECTED TOP-LEVEL EXCEPTION
这个错误有一些原因:
- 数字函数> 65k,需要开启multidex
- 有一些库是嵌套的,我们需要在 build.gradle 中添加排除。
关于第二种情况,很难检测出嵌套了什么lib。
如果你有这方面的经验,请分享给我。
更新:
dependencies {
compile files('libs/ormlite-android-4.48.jar')
compile files('libs/ormlite-core-4.48.jar')
// compile 'com.obsez.android.lib.filechooser:filechooser:1.1.2'
// compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'cn.lightsky.infiniteindicator:library:1.0.5'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.mcxiaoke.volley:library:1.0.15'
compile('com.google.apis:google-api-services-drive:v2-rev170-1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.api-client:google-api-client-android:1.20.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.android.gms:play-services:8.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.nononsenseapps:filepicker:2.4.1'
}
【问题讨论】:
-
没有最好的方法,因为原因可能不同。每种情况都有一个解决方案,其中包含 UNEXPECTED TOP-LEVEL EXCEPTION。发布您的问题,一些用户将帮助您解决
-
嗨,@GabrieleMariotti 先生,我有更新我的案例,这让我很长时间,所以我想询问一般案例。
-
发布 gradle 问题的堆栈跟踪。使用 gradlew assemble --info 获取更多详细信息。
-
嗨,Gradlew --info 没有错误并且在 logcat 中只有错误:
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_25\bin\java.exe'' finished with non-zero exit value 2 -
不幸的是它没有帮助。 UNEXPECTED TOP-LEVEL EXCEPTION 附近应该是对实际问题的简短描述。
标签: android exception build.gradle