Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 772
Tushar Gogna Avatar asked Dec 15 '22 12:12

Tushar Gogna


1 Answers

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.

like image 113
Rakesh Avatar answered Jan 17 '23 10:01

Rakesh