Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using attributes from API level beyond minSdkVersion

I am new to Android development and am wondering what happens if you use attributes on XML tags from an API level greater than your minSdkVersion.

For example having:

<uses-sdk     android:minSdkVersion="9"     android:targetSdkVersion="20" /> 

And then using this:

<activity android:logo="@drawable/iconwhatever"></activity> 

The "android:logo" attribute is from API level 11.

In Android Studio it gives the following error, but I want to know what could happen if this is left alone:

Attribute "logo" is only used in API level 11 and higher. (Current min is 9) 

Any help regarding this would be greatly appreciated.

like image 270
Michael Garner Avatar asked Oct 14 '14 18:10

Michael Garner


People also ask

Which attribute of the element is used to specify the minimum API level required for the application to run?

Declaring a minimum API Level If you build an application that uses APIs or system features introduced in the latest platform version, you should set the android:minSdkVersion attribute to the API Level of the latest platform version.

What API level should I develop for?

New apps must target Android 12 (API level 31) or higher; except for Wear OS apps, which must target Android 11 (API level 30) or higher.

What is minSdkVersion and targetSdkVersion?

minSdkVersion : The min sdk version is the minimum version of the Android operating system required to run your application. targetSdkVersion : The target sdk version is the version your app is targeted to run on. Follow this answer to receive notifications.

What does API level mean?

What is API Level? API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform. The Android platform provides a framework API that applications can use to interact with the underlying Android system.


1 Answers

Unsupported attributes are safely ignored.

From SDK documentation:

When parsing XML resources, Android ignores XML attributes that aren’t supported by the current device. So you can safely use XML attributes that are only supported by newer versions without worrying about older versions breaking when they encounter that code.

like image 97
ovmjm Avatar answered Oct 03 '22 04:10

ovmjm