Tushar Gogna
Tushar Gogna

Reputation: 5083

Android Studio: ButterKnife 6.1.0 Duplicate Class: $$View Injector

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.

default settings

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.

Upvotes: 4

Views: 741

Answers (2)

Alsor Zhou
Alsor Zhou

Reputation: 43

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.

Upvotes: 3

Rakesh
Rakesh

Reputation: 552

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.

Upvotes: 9

Related Questions