Brian Tacker
Brian Tacker

Reputation: 1122

Android find all method calls for a higher api version

I recently ran into a problem where I tested my app on an older version of Android (API 12) and my target API level is 22. When I ran it in Honeycomb it was crashing do to a method call that is for API 16.

My question is, how can I find all method calls that are for a higher version than my minSDKVersion (which is 11)? Just to make sure Im not making that mistake anywhere else in my app.

By the way, Im using Android Studio

Thanks for any help

Upvotes: 1

Views: 1200

Answers (2)

rahul.ramanujam
rahul.ramanujam

Reputation: 5618

You should be able to see the deprecated symbol like this for older api methods

enter image description here

you can also check api level and provide alternative methods like this

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    CookieManager.getInstance().removeAllCookies(null);
} else {
    CookieManager.getInstance().removeAllCookie();
}

Upvotes: 1

EE66
EE66

Reputation: 4651

  • Compile your project with the lowest api that u support. Then all of the newer methods will be with errors.
  • Run lint to see all of the warnings and filter them for @SuppressLint("NewApi")

Upvotes: 2

Related Questions