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

白昼怎懂夜的黑 提交于 2019-12-12 09:44:47

问题


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

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