Android Studio does not compile when using deprecated API

androidandroid-studiodeprecatedgradleintellij-idea

I am having issues compiling and running my application on Android Studio.

The problem: It doesn't like that I am using deprecated APIs. (from gradlew compileDebug --stacktrace. Full stacktrace here

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

The Background:

  • I am using a PreferenceActivity which uses onPreferenceTreeClick and addPreferencesFromResource(int), both deprecated methods.
  • I am using ABS and ViewPager libraries, which both seem to also be using deprecated methods in their code.

The Question:

  • Can the run configurations be edited to an extend where It can compile succesfully despite of the deprecated APIs?
  • What can be changed/edited/modified to allow the build to compile succesfully?

Given that I plan on supporting pre-ICS devices and the usage of deprecated APIS shoudln't suppose a problem.

EDIT

So, the compiler from command prompt indicates the build was succesful, problem is running from Android Studio directly, the build process fails:

FAILURE: Build failed with an exception.

The problem seems to be something I have no idea how to fix, the popular line is:

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: 

which is happening at three different places:

Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;
Landroid/support/v4/app/ActivityCompatHoneycomb;
Landroid/support/v4/app/LoaderManager;

Here's some more info: Full Compiler output in Android Studio

* What went wrong:
Execution failed for task ':LaPrensa:dexDebug'.
> Running C:\Users\SkullKandy\AppData\Local\Android\android-studio\sdk\build-tools\android-4.2.2\dx.bat failed. 

Best Solution

You have simply to add this code to build.gradle (in android section)

lintOptions {
    abortOnError false
}