1

I have an Android project with minSDK 8 and targetSDK 17. I used a call to a function introduced in API Level 9 (Camera.getNumberOfCameras()). ADT doesn't seem to mind this and compiles just fine with no warnings. I set the targetSDK to 8 as well, and it still just builds it fine with no warnings. I would really like it to warn me if my code isn't going to run on an SDK I claim to support. Is there a way to do this?

Fergusmac
  • 3,679
  • 4
  • 20
  • 24
  • Also, I gather that if I do want to call a function like this, it's not simply sufficient to enclose it in an if statement that checks the Build.VERSION of the device? – Fergusmac Jul 11 '13 at 06:01

2 Answers2

2

Just change the severity of NewApi in Android Lint Preferences to error.

Properties --> Android Lint Preferences --> NewApi --> Error in Severity box

Make sure you click the refresh icon in the Lint Warnings windows after every rebuild.

Hoan Nguyen
  • 18,033
  • 3
  • 50
  • 54
  • It's already set as Error. Other Lint warnings seem to be working fine; Eclipse is set to build automatically and other problems are picked up basically straight away. But even if I set the target and min API level to 1 and use functions from API 14 or 17, Lint doesn't report a single error. – Fergusmac Jul 11 '13 at 07:31
  • 1
    In the Lint Warnings window click the refresh icon. You can show Lint Warnings window by Window --> Show View --> Other --> Android --> Lint Warnings. – Hoan Nguyen Jul 11 '13 at 15:45
0

It appears that this is a known bug which will be fixed in the next ADT release.

See: https://code.google.com/p/android/issues/detail?id=56427

Fergusmac
  • 3,679
  • 4
  • 20
  • 24