2
NewApi error : Finds API accesses to APIs that are not supported in all targeted API versions This post has been taken from : http://code2care.org/pages/newapi- error-finds-api-accesses-to-apis-that-are-not-supported-in-all- targeted-api-versions/ NewApi error : Finds API accesses to APIs that are not supported in all targeted API versions The above lint error message is displayed for your Android project when you use a method form a API that is not supported by all the Android APIs levels that you target. Solutions : You can either change the minSdkVersion and targetSdkVersion in your AndroidManifest.xml for unsupported APIs. If you want to support all versions that you have stated in AndroidManifest then you need to use "Conditional execution" i.e. add conditions in your code based on the API level. You can also use @TargetApi annotation to set the SDK level to apply to your code, example @TargetApi(18) public class DoSomething {

Android new api error

Embed Size (px)

Citation preview

Page 1: Android new api error

NewApi error : Finds API accesses to APIs that are not supported in all targeted API versions

This post has been taken from : http://code2care.org/pages/newapi-error-finds-api-accesses-to-apis-that-are-not-supported-in-all-targeted-api-versions/

NewApi error : Finds API accesses to APIs that are not supported in all targeted

API versions

The above lint error message is displayed for your Android project when you use a

method form a API that is not supported by all the Android APIs levels that you

target.

Solutions :

You can either change the minSdkVersion and targetSdkVersion in your AndroidManifest.xml for unsupported APIs.

If you want to support all versions that you have stated in AndroidManifest then you need to use "Conditional execution" i.e. add conditions in your code based on the API level.

You can also use @TargetApi annotation to set the SDK level to apply to your code, example

@TargetApi(18)public class DoSomething {

//You Code}

Page 2: Android new api error

The above code will consider API level 18 rather than the what is being defined in the AndroidManifest.xml file. But not that you cannot use @TargetApi for a method.

You can use tools:targetApi="" in the Android XML files to support certain API

levels.

For more visit : http://code2care.org