“trouble writing output: Too many field references: 70185; max is 65536. You may try using --multi-dex option.” when building Android project

。_饼干妹妹 提交于 2019-11-30 20:13:26

The solution was to change the package in the AndroidManifest to match the main application's package.

A manifest like this:

<manifest package="com.example.testlibrary" ...

resulted in 6k+ fields and build failure. Changing it to match the main application's package

<manifest package="com.example.mainapplication" ...

resulted in the project building successfully.

Note that only the package in the manifest is changing, I did not make any changes to the library's Java source or its layout (the Java package was still com.example.testlibrary with directory structure to match).

I hypothesize that the different package name is causing all the Android fields to be included again under that package. All the packages in the error listing with 6k+ fields had a different package name than the main application.

I also (later, grr), found this blog post which details the same problem and the eventual same solution.

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