Multiple dex files define Landroid/support/v7/util/ThreadUtil$MainThreadCallback Error

北城以北 提交于 2019-12-02 09:59:04
CommonsWare

Per your comment, apparently the issue was a third-party SDK that distributed a JAR of recyclerview-v7, that you had in libs/, which conflicted with your recyclerview-v7 dependency.

There are downsides to using plain JARs for dependencies.

One is that you tend to forget about them, particularly if you also are using dependencies from artifact repositories. For example, I didn't even consider that you might have JARs in libs/ in my comment.

Another is that Gradle cannot perform any sort of dependency resolution for them. Gradle relies on artifact metadata (POM files) for determining what dependencies are required. Gradle assumes that "you're doing the right thing" with respect to JAR files, and in this case, your ad network's one JAR isn't "the right thing".

Also, JARs are JARs, not AARs. In this case, the engineers at your ad network are very strange people. recyclerview-v7 has resources in its AAR that RecyclerView needs (e.g., custom attributes). Basically, by distributing a JAR containing RecyclerView code, they are dooming anyone using their SDK: nobody can use their RecyclerView because it is incomplete (and probably out of date), and nobody can use the official RecyclerView due to class conflicts.

At minimum, I recommend that you complain to the ad network, urging them to switch to using artifacts and a proper set of dependencies.

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