본문 바로가기

Android

[Android] Understand API levels and compatibility

* Understand API levels and compatibility

- API levels:

  • Each Android OS has an official version number and name (for example Android 9.0, "Pie") and an API level (API 28). Use the API levels in your app's Gradle files to indicate the versions of Android your app supports.
  • The compileSdkVersion parameter in the build.gradle file specifies the Android API level that Gradle should use to compile your app.
  • The targetSdkVersion parameter specifies the most recent API level that you have tested your app against. In many cases this parameter has the same value as compileSdkVersion.
  • The minSdkVersion parameter specifies the oldest API level your app can run on.

- Android Jetpack:

  • Android Jetpack is a collection of libraries, developed by Google, that offers backward-compatible classes and helpful functions for supporting older versions of Android. Jetpack replaces and expands on the set of libraries formerly known as the Android Support Library.
  • Classes imported from the androidx package refer to the Jetpack libraries. Dependencies to Jetpack in your build.gradle file also start with androidx. (ex: implementation 'androidx.appcompat:appcompat:1.0.0-beta01')

 

- Backward compatibility for vector drawables:

  • Vector drawables are only natively supported in versions of Android higher than API 21. In older versions, Gradle generates PNG images for those drawables when your app is built.
  • You can specify that the Android Support Library should be used for vector drawables in older API versions with the vectorDrawables.useSupportLibrary = true configuration parameter in the build.gradle file.
  • Once you've enabled the support library for vector drawables, use the app:srcCompat attribute in the <ImageView> element (instead of android:src) to specify the vector drawable source for that image.

- The app namespace:

  • The app namespace in your XML layout file is for attributes that come from either your custom code or from libraries, not from the core Android framework.

 

*참고: https://codelabs.developers.google.com/codelabs/kotlin-android-training-images-compat/#5

 

Android Kotlin Fundamentals 01.3: Image resources and compatibility

At the end of the last codelab, you had an app that updates a text view with a number between 1 and 6 each time the user taps a button. However, the app is called DiceRoller, not 1-6 Number Generator, so it would be nice if the dice actually looked like di

codelabs.developers.google.com