Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Activity uses or overrides a deprecated API

Tags:

android

realm

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?

like image 374
Subby Avatar asked Jun 06 '15 13:06

Subby


People also ask

How do you fix uses or overrides a deprecated API?

You can resolve this warning message by using recommned API. In our example, we should use setVisible(true) rather than show() method. When you will compile above code, you won't get warning message anymore. That's all about how to fix uses or overrides a deprecated api.

How does Android handle deprecated methods?

What happens if i continue using Deprecated methods? Code would continue running as it is until method is removed from SDK. If you are using deprecated method then you must keep track of removed apis whenever you upgrade to newest SDK. If you don't want a change at all then check for the reason behind deprecation.

What is deprecated API in Android?

Deprecation means that we've ended official support for the APIs, but they will continue to remain available to developers. This page highlights some of the deprecations in this release of Android. To see other deprecations, refer to the API diff report.

What is the purpose of MainActivity Java?

Android Studio created an activity for us called MainActivity. java. The activity specifies what the app does and how it should respond to the user.


1 Answers

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'
  }
}
like image 163
Christian Melchior Avatar answered Sep 29 '22 12:09

Christian Melchior