I hit this error and did not find any hits for the error message, so I decided to share with the solution that I came up with to save anyone else who was faced with a problem repeating my work.
When writing a new Android library (apklib) for use in a (large) application, I get the following error during dexing when I add my new project to the dependency:
write problem: too many field references: 70185; max - 65536.
You can try using the -multi-dex option.
Packaging links:
<... long list of packets with field count rejected ...>
The specific build step with which it comes out is:
java -jar $ANDROID_SDK/build-tools/19.0.3/lib/dx.jar --dex \ --output=$PROJECT_HOME/target/classes.dex \ <... long list of apklib and jar dependencies elided ...>
Using --multi-dex , as recommended in the error message, may be a solution, but I am not the owner of the application project and it already has a big complex build process that I would hesitate to change independently.
I can reproduce this problem with a project without a test library that has literally no fields, but it contains 6000+ fields in the error output. Of the packages listed in the error output, there are a handful with similar 6k + field counts, but then the vast majority have more likely field counts <1k.
This problem is similar to the Too Many Methods problem, which Facebook famously hacked into . The FB solution seems insane, and the only other solutions that I found (for example, this big Android code , or this , this SO answer , this other SO answer ) are all related to changing the main application code, which goes beyond what I I want to make.
Is there any other solution?