Android Studio Error "UNEXPECTED TOP-LEVEL EXCEPTION"

本文介绍了一种常见的Android开发问题:使用ActionBarSherlock时出现的AndroidDex错误。问题通常由于主工程与ActionBarSherlock模块重复引用android-support-v4.jar导致。文中提供了解决方案,即移除重复的jar包。

用Android Studio 部署程序的时候,如果需要引入ABS( ActionBarSherlock) ,并且完成了ActionBarSherlock的模块设置以后,有时会出现如下错误:

Android Dex: [App Name] UNEXPECTED TOP-LEVEL EXCEPTION:

则可以用一下方法解决:

打开项目设置,知道工程所应用的lib包目录,选中lib包目录下的android-support-v4.jar, 把它去除,因为在ActionBarSherlock工程里面已经引入的该jar,使得主工程模块与ActionBarSherlock工程模块重复引用了同一个jar包。



PS D:\ASSimpleDemo> ./gradlew build --warning-mode all Configuration on demand is an incubating feature. > Configure project : The RepositoryHandler.jcenter() method has been deprecated. This is scheduled to be removed in Gradle 8.0. JFrog announced JCenter's shutdown in February 2021. Use mavenCentral() instead. Consult the upgrading guide for further information: https://docs.gradle.org/7.0.2/userguide/upgrading_version_6.html#jcenter_deprecation at build_ce3ruzx0et0a87btopefgvs46$_run_closure1$_closure2.doCall(D:\ASSimpleDemo\build.gradle:11) (Run with --stacktrace to get the full stack trace of this deprecation warning.) > Configure project :app WARNING:Using flatDir should be avoided because it doesn't support any meta-data formats. Warning: This version only understands SDK XML versions up to 2 but an SDK XML file of version 3 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times. Warning: 意外的元素 (uri:"", local:"extension-level")。所需元素为<{}codename>,<{}layoutlib>,<{}api-level> Warning: 意外的元素 (uri:"", local:"base-extension")。所需元素为<{}codename>,<{}layoutlib>,<{}api-level> WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 34 This Android Gradle plugin (7.0.2) was tested up to compileSdk = 31 This warning can be suppressed by adding android.suppressUnsupportedCompileSdk=34 to this project's gradle.properties The build will continue, but you are strongly encouraged to update your project to use a newer Android Gradle Plugin that has been tested with compileSdk = 34 > Task :app:processReleaseMainManifest D:\ASSimpleDemo\app\src\main\AndroidManifest.xml:21:5-79 Warning: Element uses-permission#android.permission.ACCESS_FINE_LOCATION at AndroidManifest.xml:21:5-79 duplicated with element declared at AndroidManifest.xml:12:5-79 D:\ASSimpleDemo\app\src\main\AndroidManifest.xml:22:5-65 Warning: Element uses-permission#android.permission.CAMERA at AndroidManifest.xml:22:5-65 duplicated with element declared at AndroidManifest.xml:16:5-64 D:\ASSimpleDemo\app\src\main\AndroidManifest.xml:23:5-80 Warning: Element uses-permission#android.permission.READ_EXTERNAL_STORAGE at AndroidManifest.xml:23:5-80 duplicated with element declared at AndroidManifest.xml:18:5-80 D:\ASSimpleDemo\app\src\main\AndroidManifest.xml:24:5-81 Warning: Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at AndroidManifest.xml:24:5-81 duplicated with element declared at AndroidManifest.xml:5:5-81 > Task :app:processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > AAPT2 aapt2-7.0.2-7396180-windows Daemon #0: Unexpected error during link, attempting to stop daemon. This should not happen under normal circumstances, please file an issue if it does. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 8s 36 actionable tasks: 12 executed, 24 up-to-date
最新发布
06-24
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值