Search code examples
androidcompatibility

How to force checking for incompatible API usage in Android code?


I have set minSdk to 7 and targetSdk to 17.

I find the problems by manually checking if something crashes. (Yes this is nonsense)

I tried setting targetSdk to 7 too. But that doesn't help either. I think I am missing a setting which still thinks that the target is 17.

How can I be sure that I am not using any incompatible code? I at least need warnings. For sure I check for build version to dynamically call higher level APIs or not, but I want to be sure that I have surrounded any possible code that may make the app crash on lower versions of Android.


Solution

  • How can I be sure that I am not using any incompatible code?

    Assuming that you are using a reasonably recent version of the Android tools (e.g., something in the past year), Lint will point out to you anything that you are using that is newer than your android:minSdkVersion but is allowed by your build target.

    If you are using Eclipse, this should happen automatically when you save source files, or you can manually run Lint on your project by right-clicking over the project in Package Explorer, then choosing Android Tools > Run Lint: Check for Common Errors.