Hello! I'm having this issue when I try to run my project, seems for Windows or Linux runs ok, but not for MacOs.
Error:Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider butterknife.compiler.ButterKnifeProcessor could not be instantiated: java.lang.NoSuchMethodError: com.squareup.javapoet.CodeBlock.of(Ljava/lang/String;[Ljava/lang/Object;)Lcom/squareup/javapoet/CodeBlock;
This is my gradle.file
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "xxxxxx"
minSdkVersion xxxx
targetSdkVersion xxx
versionCode xxx
versionName "xxxx"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{
testCoverageEnabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
jumboMode = true
}
testOptions {
unitTests.returnDefaultValues = true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
ext {
supportLibVersion = "25.3.1"
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.ogaclejapan.smarttablayout:library:1.2.1@aar'
compile 'org.nibor.autolink:autolink:0.6.0'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.github.fafaldo:fab-toolbar:1.2.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.6.3'
compile 'it.sephiroth.android.library.imagezoom:imagezoom:2.2.5'
compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'net.danlew:android.joda:2.9.9'
compile 'com.github.bumptech.glide:glide:3.8.0'
compile 'jp.wasabeef:glide-transformations:2.0.2'
// If you want to use the GPU Filters
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
//For xmpp
compile "org.igniterealtime.smack:smack-android:4.2.0"
compile "org.igniterealtime.smack:smack-tcp:4.2.0"
compile "org.igniterealtime.smack:smack-im:4.2.0"
compile "org.igniterealtime.smack:smack-extensions:4.2.0"
//Crash reports
compile 'com.instabug.library:instabug:4.2.6'
//For Dagger
compile 'com.google.dagger:dagger:2.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.2'
provided 'org.glassfish:javax.annotation:10.0-b28'
//Butterknife
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//Testing
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile "org.powermock:powermock-module-junit4:1.6.2"
testCompile "org.powermock:powermock-module-junit4-rule:1.6.2"
testCompile "org.powermock:powermock-api-mockito:1.6.2"
testCompile "org.powermock:powermock-classloading-xstream:1.6.2"
//compile 'com.kbeanie:multipicker:1.1.31@aar'
//compile 'com.kcthota:emoji4j:5.0'
compile 'com.linchaolong.android:imagepicker:1.5'
}
This is happening because something is forcing Gradle to use an older version of JavaPoet than what ButterKnife requires. You can probably fix this by updating Dagger to the latest, or by explicitly specifying an annotationProcessor dependency on the latest version of JavaPoet.
In reality, though, this is a Gradle bug, and I would encourage you to report it to them. The fact that both Dagger and ButterKnife use JavaPoet as a dependency should mean that Gradle resolves the newer version of two, and not just the first version that's requested.
Great! it was a fast answer, I'll do it.
Most helpful comment
This is happening because something is forcing Gradle to use an older version of JavaPoet than what ButterKnife requires. You can probably fix this by updating Dagger to the latest, or by explicitly specifying an annotationProcessor dependency on the latest version of JavaPoet.
In reality, though, this is a Gradle bug, and I would encourage you to report it to them. The fact that both Dagger and ButterKnife use JavaPoet as a dependency should mean that Gradle resolves the newer version of two, and not just the first version that's requested.