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.
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.
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.
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 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With