Butterknife: Build fail

Created on 5 Nov 2017  ·  7Comments  ·  Source: JakeWharton/butterknife

When I try to run my app, I get the following error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $

I've been searching for the cause of this error and it seems like there is something wrong with the build:gradle 3.0. This is the build.gradle file for my app:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "tesiselectronica.signalclassifier"
        minSdkVersion 22
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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:25.4.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    testCompile 'junit:junit:4.12'
} 

I hope this is enough information sa that a solution can be given. Thank you very much.

All 7 comments

I have the same problem, have you solved it?

No it seems, that the error occurs when I changed from gradle build 2.3 to version 3.0. However, I haven't found a solution.

I found this method in another issues
在defaultConfig中加入(Adding it in defaultConfig)
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
就可以继续用7.0.1(You can continue to use version7.0.1)

gradle version 3.0

It's not clear why you think this is a Butter Knife issue. It appears to either be an Android Gradle plugin bug or something wrong with your build configuration.

Yes, it seems to be a bug but it only appears when I use Butterknife in my gradle build. Thank you @zhjingb for your solution, it works fine.

For myself I had to add this to my gradle after defaultConfig and it worked :

lintOptions {
checkReleaseBuilds false
}

Hope it will be useful

is it safe?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anthony3444 picture anthony3444  ·  3Comments

galibimtiaz picture galibimtiaz  ·  3Comments

mturki picture mturki  ·  3Comments

Pitel picture Pitel  ·  3Comments

ernestp picture ernestp  ·  3Comments