Android - Activity uses or overrides a deprecated API

68,544

Solution 1

It looks like you are also using Butterknife? Have you tried adding the below to your build.gradle:

android {
  ...

  packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
  }
}

Solution 2

Adding this to the android plugin in build.gradle tends to fix these sorts of problems:

    packagingOptions {
        // Exclude file to avoid
        // Error: Duplicate files during packaging of APK
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
        exclude 'META-INF/*.kotlin_module'
    }
}

Solution 3

Adding these on build.gradle as Specified in ButterKnife I/O page.

android{
....
packagingOptions {
  exclude 'META-INF/services/javax.annotation.processing.Processor'
}


}

lintOptions {
  disable 'InvalidPackage'
}
Share:
68,544
Subby
Author by

Subby

Love Software.

Updated on January 04, 2021

Comments

  • Subby
    Subby over 3 years

    I have literally created a brand new Android Project on the latest Android Studio. The first thing I did was to add the `Realm' library to the project by adding the following to the gradle file:

    compile 'io.realm:realm-android:0.80.3'
    

    If I try to compile, I get the following error:

    Note: C:\....\MainActivity.java uses or overrides a deprecated API.
    

    Origin 2: C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\io.realm\realm-android\0.80.3\7979d05ba7b919c53766bf98e31aaf0e9feb0590\realm-android-0.80.3.jar Error:duplicate files during packaging of APK C:...\app\build\outputs\apk\app-debug-unaligned.apk Path in archive: META-INF/services/javax.annotation.processing.Processor Origin 1: C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\6.1.0\63735f48b82bcd24cdd33821342428252eb1ca5a\butterknife-6.1.0.jar You can ignore those files in your build.gradle: android {
    packagingOptions { exclude 'META-INF/services/javax.annotation.processing.Processor' } Error:Execution failed for task ':app:packageDebug'.

    Duplicate files copied in APK META-INF/services/javax.annotation.processing.Processor File 1: C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\6.1.0\63735f48b82bcd24cdd33821342428252eb1ca5a\butterknife-6.1.0.jar File 2: C:\Users\Usmaan.gradle\caches\modules-2\files-2.1\io.realm\realm-android\0.80.3\7979d05ba7b919c53766bf98e31aaf0e9feb0590\realm-android-0.80.3.jar }

    Any ideas?

  • natsumiyu
    natsumiyu almost 5 years
    where to add this?
  • Filippos Zofakis
    Filippos Zofakis over 3 years
    In module-level gradle (app/build.gradle), inside android {}, for example next to lintOptions or defaultConfig
  • Bay
    Bay over 3 years
    Also I use: exclude("META-INF/*.kotlin_module")
  • EpicPandaForce
    EpicPandaForce over 3 years
    @Bay good catch, I also had to start including that.