Compilation error with ButterKnife: error duplicate class

1.1k views Asked by At

I get this error when I build my project:

error: duplicate class: class_name$$ViewInjector

enter image description here

This is my build.gradle file:

apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion "19.1.0"

defaultConfig {
    applicationId "com.stel.order"
    minSdkVersion 9
    targetSdkVersion 19
}

buildTypes {
    release {
        runProguard true
        proguardFiles 'proguard-project.txt'
    }
}
}

dependencies {  
  compile 'com.google.code.gson:gson:2.2.4'   
  compile 'com.jakewharton:butterknife:6.0.0'
  ...
}

If I clean the project, it builds without errors, but when I run the project, I get this error.

2

There are 2 answers

1
Alex Zaitsev On

It happened with me too when I migrated from Eclipse. All you need is to delete files path.OuterClass$$ViewInjector in your project manually.

1
Jack Huang On

1: Remove the eclipse project .apt_generated file folders and .factorypath 2: Remove .classpath file node 3: re-imported into the android studio

1:删除eclipse项目中的.apt_generated文件夹和.factorypath文件 2:删除.classpath文件中的节点 3:重新导入到android studio中