问题
I migrated my project to AS from Eclipse as I was getting 65K methods issue. After fixing every dependency issue that I was facing initially with AS, I got stuck with this issue which doesn't seem to go away no matter what I try from the other similar posts from around the blogs and SO itself.
I checked Enable Annotation Processing in Annotation Processors and also gave a processor path. (even tried with Obtain processor from project classpath) but whenever I run the project it gives the following error:
Error:(8, 8) error: duplicate class: list.EventsListAdapter$ViewHolder$$ViewInjector
Error:Execution failed for task ':ProjectDemo:compileDebugJava'.
Compilation failed; see the compiler error output for details.
In my gradle file, I added the following as per the suggestions by others:
applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
}
}
But the result was the same.
What am I doing wrong? Also, let me know if you want more details regarding this. I'm kinda new to AS and might have missed something obvious.
Thanks in advance.
回答1:
I also faced this issue. This issue occurred when user imported project from eclipse's workspace. Actually it copies the $$ViewInjector.java
files in your src
folder. So you need to delete them from your src
packages manually.
回答2:
Sorry, don't have the reputation to add the comment to @Rakesh's answer (he is right).
It also happens when "refactor - move package" with wrong options.
来源:https://stackoverflow.com/questions/32219175/android-studio-butterknife-6-1-0-duplicate-class-view-injector