Different Between 𝐜𝐨𝐦𝐩𝐒π₯πžπ’ππ€π•πžπ«π¬π’π¨π§ and π­πšπ«π πžπ­π’ππ€π•πžπ«π¬π’π¨π§

In this android blog article, Let’s Understand the major different between compileSdkVersion & targetSdkVersion in Android Development, This both CompileSdkVersion and TargetSdkVersion are very important settings that is configured into Android project while creating new project under build.gradle file. They simply tells developer that which Android SDK version is been used to compile the code & which while be highest device it the app will support. Here’s the difference between the two:

Android compileSdkVersion

𝐜𝐨𝐦𝐩𝐒π₯πžπ’ππ€π•πžπ«π¬π’π¨π§ specifies which version of Android SDK will be used by android gradle to compile you android project. This means that your andriod application has the ability to use all that APIs is is been included into the specified version and less then specified version.

𝐅𝐨𝐫 π„π±πšπ¦π©π₯𝐞, If your android project is set to 𝐜𝐨𝐦𝐩𝐒π₯πžπ’ππ€π•πžπ«π¬π’π¨π§ to 30, it means that your android application has access to use all the APIs up to version 30. For example, let’s assume you want Camera2 API to be used, But the Camera2 API was introduced with Android 5.0 (i.e. API Level 21) and above, and you have already set 𝐜𝐨𝐦𝐩𝐒π₯πžπ’ππ€π•πžπ«π¬π’π¨π§ to 30, That means you can use Camera2 API without any issue. However, suppose you set compileSdkVersion lower then API Level 21 and you are trying to make use of Camera2 API, then you will get compile-time error because Camera2 API is not available below 𝐜𝐨𝐦𝐩𝐒π₯πžπ’ππ€π•πžπ«π¬π’π¨π§ 21.

Android targetSdkVersion

π­πšπ«π πžπ­π’ππ€π•πžπ«π¬π’π¨π§ This version defines tell the android OS on which android SDK version the Application was designed and tested on and also indicates the API version the app is of compatibility and can run smoothly.

𝐅𝐨𝐫 π„π±πšπ¦π©π₯𝐞, suppose your android project π­πšπ«π πžπ­π’ππ€π•πžπ«π¬π’π¨π§ is set to 30, It Means that you has designed the app to run on device that support android 30 and above, and you made it sure that your android application will work smoothly abd behaves correctly as accepted on those devices.

Conclusion

πŸ“ The summary, the compileSdkVersion, determines a set of APIs that is been used for the build process, while the targetSdkVersion specifies the intended API level for the app and indicates its compatibility with newer Android versions.

🎯 Ideally, the compileSdkVersion and targetSdkVersion should match, both pointing to the latest SDK. However, it’s crucial to thoroughly test the app’s compatibility with the changes introduced in that version.

πŸ’‘ Therefore, understanding the distinction between compileSdkVersion and targetSdkVersion is vital for effective utilization in Android development projects. This ensures optimization, thorough testing, and smooth functioning of your app across various devices. Happy coding! πŸ’»πŸ“±πŸš€