0

I was trying to deal with this error (which I never had before I update something in Android Studio):

Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - auto-value-1.4.jar (com.google.auto.value:auto-value:1.4) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

So I added an annotation processor: annotationProcessor 'com.google.auto.value:auto-value:1.4'.

And now, a new error is shown:

More than one file was found with OS independent path 'META-INF/DEPENDENCIES'

Question

I read that I should change packaging options (More than one file was found with OS independent path 'META-INF/LICENSE' + Error : More than one file was found with OS independent path 'META-INF/LICENSE' + etc.).

But, instead, is there a way to solve the first problem without triggering the second with only a few changes on my App build.gradle? It would be better.

build.gradle (app level)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.x.x"
        minSdkVersion 26
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        renderscriptTargetApi 26
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.google.firebase:firebase-admin:6.5.0'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.github.mancj:MaterialSearchBar:0.7.6'

    annotationProcessor 'com.google.auto.value:auto-value:1.4'
}
JarsOfJam-Scheduler
  • 2,809
  • 3
  • 31
  • 70

1 Answers1

2

you can either exclude the file altogether or limit it to one occurrence:

android {

    ...
    packagingOptions {
        // pickFirst "META-INF/DEPENDENCIES"
        exclude "META-INF/DEPENDENCIES"
    }
}
Martin Zeitler
  • 1
  • 19
  • 155
  • 216