当我使应用程序使用许多库时。我通常遇到错误UNEXPECTED TOP-LEVEL EXCEPTION
此错误有以下原因:
关于第二种情况,很难检测出嵌套的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'
}
答案 0 :(得分:5)
解决意外的顶级异常的最佳方法是什么? 我会建议你这个两个步骤来解决这个问题。
首先发现在maven / jcenter / mavencentral附加/编译的库中使用的依赖项。主要问题将得到支持,因为它可能是support-v4& appcompact已经包含在从maven附加的库中(比如播放服务包含v4,appcompact附加然后不需要附加support-v4,因为它已经包含。)
如何在gradle中检查附加库的依赖关系/层次结构
Gradle菜单> :modulename>>任务>> android>>运行" androidDependcies"
OR
Gradle菜单> :app>>任务>> android>>运行" androidDependcies"
通过在 Gradle Console 中执行此操作,您将得到类似下面的内容作为输出(输出可能取决于附加的库)。哪些可以了解库的重复/层次结构
release
+--- LOCAL: picasso-2.5.2.jar
+--- LOCAL: YouTubeAndroidPlayerApi.jar
+--- LOCAL: commons-lang-2.6.jar
+--- LOCAL: signpost-core-1.2.1.1.jar
+--- LOCAL: kxml2_2.3.0.jar
+--- LOCAL: classes.jar
+--- LOCAL: signpost-commonshttp4-1.2.1.1.jar
+--- LOCAL: json-simple-1.1.1.jar
+--- LOCAL: universal-image-loader-1.9.3.jar
+--- LOCAL: linkedin-j-.jar
+--- LOCAL: maps.jar
+--- LOCAL: nineoldandroids-2.4.0.jar
+--- com.android.support:multidex:1.0.1
+--- com.android.support:multidex:1.0.1
+--- com.android.support:appcompat-v7:23.1.1
| \--- com.android.support:support-v4:23.1.1
| \--- LOCAL: internal_impl-23.1.1.jar
+--- com.google.android.gms:play-services-maps:7.3.0
| \--- com.google.android.gms:play-services-base:7.3.0
| \--- com.android.support:support-v4:23.1.1
| \--- LOCAL: internal_impl-23.1.1.jar
+--- com.google.android.gms:play-services-gcm:7.3.0
| \--- com.google.android.gms:play-services-base:7.3.0
| \--- com.android.support:support-v4:23.1.1
| \--- LOCAL: internal_impl-23.1.1.jar
+--- com.google.android.gms:play-services-location:7.3.0
| +--- com.google.android.gms:play-services-base:7.3.0
| | \--- com.android.support:support-v4:23.1.1
| | \--- LOCAL: internal_impl-23.1.1.jar
| \--- com.google.android.gms:play-services-maps:7.3.0
| \--- com.google.android.gms:play-services-base:7.3.0
| \--- com.android.support:support-v4:23.1.1
| \--- LOCAL: internal_impl-23.1.1.jar
+--- com.google.android.gms:play-services-ads:7.3.0
| +--- com.google.android.gms:play-services-base:7.3.0
| | \--- com.android.support:support-v4:23.1.1
| | \--- LOCAL: internal_impl-23.1.1.jar
| \--- com.google.android.gms:play-services-analytics:7.3.0
| \--- com.google.android.gms:play-services-base:7.3.0
| \--- com.android.support:support-v4:23.1.1
| \--- LOCAL: internal_impl-23.1.1.jar
+--- com.google.android.gms:play-services-analytics:7.3.0
| \--- com.google.android.gms:play-services-base:7.3.0
| \--- com.android.support:support-v4:23.1.1
| \--- LOCAL: internal_impl-23.1.1.jar
+--- com.google.android.gms:play-services-plus:7.3.0
| \--- com.google.android.gms:play-services-base:7.3.0
| \--- com.android.support:support-v4:23.1.1
| \--- LOCAL: internal_impl-23.1.1.jar
\--- com.android.support:recyclerview-v7:23.1.1
\--- com.android.support:support-v4:23.1.1
\--- LOCAL: internal_impl-23.1.1.jar
您也可以在终端上查看以上流程。
gradlew app:dependencies
您可以查看以下图片为"图片胜过千言万语"
如何检查导致重复输入/方法计数的类别超过65k?
而不是检查消息或错误您正在获取android studio的消息标签,请在 Gradle Console
中查看如果在将消息传递给dex :app:transformClassesWithDexForDebug
或:app:transformClassesWithDexForRelease
时,消息错误就像是多次dex(方法超过65k限制)。
或者,如果任何其他错误将指定重复条目相关等。