Примечание: С выпуском Android 9.0 (уровень API 28) появилась новая версия библиотеки поддержки AndroidX , которая является частью Jetpack . Библиотека AndroidX содержит существующую библиотеку поддержки, а также включает в себя последние компоненты Jetpack.
Вы можете продолжать использовать библиотеку поддержки. Исторические артефакты (версии 27 и более ранние, упакованные как android.support.*
) останутся доступны в Google Maven. Однако вся разработка новых библиотек будет осуществляться в библиотеке AndroidX .
Мы рекомендуем использовать библиотеки AndroidX во всех новых проектах. Также стоит рассмотреть возможность миграции существующих проектов на AndroidX.
Способ настройки библиотек поддержки Android в вашем проекте разработки зависит от того, какие функции вы хотите использовать и какой диапазон версий платформы Android вы хотите поддерживать в своем приложении.
В этом документе описываются процедуры загрузки пакета библиотек поддержки и добавления библиотек в среду разработки.
Библиотеки поддержки теперь доступны в репозитории Maven от Google. Мы больше не поддерживаем загрузку библиотек через SDK Manager, и эта функция скоро будет удалена.
Выбор вспомогательных библиотек
Прежде чем добавлять библиотеку поддержки в своё приложение, определите, какие функции вы хотите включить и какие версии Android вы хотите поддерживать. Подробнее о функциях, предоставляемых различными библиотеками, см. в разделе «Функции библиотеки поддержки» .
Добавление вспомогательных библиотек
Чтобы использовать библиотеку поддержки, необходимо изменить зависимости classpath проекта вашего приложения в среде разработки. Эту процедуру необходимо выполнить для каждой библиотеки поддержки, которую вы хотите использовать.
Чтобы добавить библиотеку поддержки в проект вашего приложения:
- Включите репозиторий Maven от Google в файл
settings.gradle
вашего проекта. dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
// If you're using a version of Gradle lower than 4.1, you must
// instead use:
//
// maven {
// url 'https://maven.google.com'
// }
}
}
- Для каждого модуля, в котором вы хотите использовать библиотеку поддержки, добавьте её в блок
dependencies
файла build.gradle
модуля. Например, чтобы добавить библиотеку core-utils версии 4, добавьте следующее: dependencies {
...
implementation "com.android.support:support-core-utils:28.0.0"
}
Внимание: использование динамических зависимостей (например, palette-v7:23.0.+
) может привести к неожиданным обновлениям версий и регрессионной несовместимости. Рекомендуем явно указывать версию библиотеки (например, palette-v7:28.0.0
).
Использование API библиотеки поддержки
Классы библиотеки поддержки, которые обеспечивают поддержку существующих API фреймворка, обычно имеют то же имя, что и класс фреймворка, но расположены в пакетах классов android.support
или имеют суффикс *Compat
.
Внимание: При использовании классов из библиотеки поддержки убедитесь, что вы импортируете класс из соответствующего пакета. Например, при применении класса ActionBar
:
-
android.support.v7.app.ActionBar
при использовании библиотеки поддержки. -
android.app.ActionBar
при разработке только для API уровня 11 или выше.
Примечание: После включения библиотеки поддержки в проект вашего приложения мы настоятельно рекомендуем сжать, обфусцировать и оптимизировать приложение перед выпуском. Помимо защиты исходного кода с помощью обфускации, сжатие удаляет неиспользуемые классы из всех библиотек, включаемых в приложение, что позволяет максимально уменьшить размер загружаемого приложения.
Дополнительные инструкции по использованию некоторых функций библиотеки поддержки представлены в учебных курсах , руководствах и примерах для разработчиков Android. Подробнее об отдельных классах и методах библиотеки поддержки см. в пакетах android.support
в справочнике по API.
Изменения декларации манифеста
Если вы повышаете обратную совместимость своего приложения с более ранней версией Android API с помощью библиотеки поддержки, обязательно обновите манифест приложения. В частности, необходимо обновить элемент android:minSdkVersion
тега <uses-sdk>
в манифесте, указав новый, более низкий номер версии, как показано ниже:
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23" />
Настройка манифеста сообщает Google Play, что ваше приложение может быть установлено на устройствах с Android 4.0 (уровень API 14) и выше.
Если вы используете файлы сборки Gradle, настройка minSdkVersion
в файле сборки переопределяет настройки манифеста.
plugins {
id 'com.android.application'
}
android {
...
defaultConfig {
minSdkVersion 16
...
}
...
}
В этом случае настройка файла сборки сообщает Google Play, что вариант сборки по умолчанию вашего приложения может быть установлен на устройствах с Android 4.1 (уровень API 16) и выше. Подробнее о вариантах сборки см. в разделе Обзор системы сборки .
Примечание: Если вы включаете несколько вспомогательных библиотек, минимальная версия SDK должна быть максимальной , требуемой для любой из указанных библиотек. Например, если ваше приложение включает как библиотеку Preference Support v14 , так и библиотеку Leanback v17 , минимальная версия SDK должна быть 17 или выше.
Контент и образцы кода на этой странице предоставлены по лицензиям. Java и OpenJDK – это зарегистрированные товарные знаки корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-08-27 UTC.
[null,null,["Последнее обновление: 2025-08-27 UTC."],[],[],null,["**Note:** With the release of Android 9.0 (API level 28) there is\na new version of the support library called\n[AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack).\nThe AndroidX library\ncontains the existing support library and also includes the latest Jetpack components.\n\n\u003cbr /\u003e\n\n\nYou can continue to use the support library.\nHistorical artifacts (those versioned 27 and earlier, and packaged as `android.support.*`) will\nremain available on Google Maven. However, all new library development\nwill occur in the [AndroidX](/jetpack/androidx) library.\n\n\u003cbr /\u003e\n\n\nWe recommend using the AndroidX libraries in all new projects. You should also consider\n[migrating](/jetpack/androidx/migrate) existing projects to AndroidX as well.\n\nHow you setup the Android Support Libraries in your development project depends on what features\nyou want to use and what range of Android platform versions you want to support with your\napplication.\n\nThis document guides you through downloading the Support Library package and adding libraries\nto your development environment.\n\nThe support libraries are now available through Google's Maven\nrepository. We no longer support downloading the libraries through the SDK\nManager, and that functionality will be removed soon..\n\nChoosing Support Libraries\n\nBefore adding a Support Library to your application, decide what features you want to include\nand the lowest Android versions you want to support. For more information on the features\nprovided by the different libraries, see\n[Support Library Features](/tools/support-library/features).\n\nAdding Support Libraries\n\nIn order to use a Support Library, you must modify your application's project's\nclasspath dependencies within your development environment. You must perform this procedure for\neach Support Library you want to use.\n\nTo add a Support Library to your application project:\n\n1. Include Google's Maven repository in your project's `settings.gradle` file. \n\n ```groovy\n dependencyResolutionManagement {\n repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n repositories {\n google()\n\n // If you're using a version of Gradle lower than 4.1, you must\n // instead use:\n //\n // maven {\n // url 'https://maven.google.com'\n // }\n }\n }\n ```\n2. For each module in which you want to use a Support Library, add the library in the `dependencies` block of the module's `build.gradle` file. For example, to add the v4 core-utils library, add the following: \n\n ```groovy\n dependencies {\n ...\n implementation \"com.android.support:support-core-utils:28.0.0\"\n }\n ```\n\n\n**Caution:** Using dynamic dependencies (for example,\n`palette-v7:23.0.+`) can cause unexpected version updates and\nregression incompatibilities. We recommend that you explicitly specify a\nlibrary version (for example, `palette-v7:28.0.0`).\n\nUsing Support Library APIs\n\nSupport Library classes that provide support for existing framework APIs typically have the\nsame name as framework class but are located in the `android.support` class packages,\nor have a `*Compat` suffix. \n**Caution:** When using classes from the Support Library, be certain you import\nthe class from the appropriate package. For example, when applying the `ActionBar`\nclass:\n\n- `android.support.v7.app.ActionBar` when using the Support Library.\n- `android.app.ActionBar` when developing only for API level 11 or higher.\n\n\n**Note:** After including the Support Library in your application project, we\nstrongly recommend that you [shrink, obfuscate, and optimize\nyour app](/studio/build/shrink-code) for release. In addition to protecting your source code with obfuscation, shrinking\nremoves unused classes from any libraries you include in your application, which keeps the\ndownload size of your application as small as possible.\n\nFurther guidance for using some Support Library features is provided in the Android developer\n[training classes](/training),\n[guides](/guide/components)\nand samples. For more information about the individual Support Library classes and methods, see\nthe [android.support](/reference/android/support/v4/app/package-summary) packages in the API reference.\n\nManifest Declaration Changes\n\nIf you are increasing the backward compatibility of your existing application to an earlier\nversion of the Android API with the Support Library, make sure to update your application's\nmanifest. Specifically, you should update the `android:minSdkVersion`\nelement of the [`\u003cuses-sdk\u003e`](/guide/topics/manifest/uses-sdk-element) tag in the manifest to the new, lower version number, as\nshown below: \n\n```xml\n \u003cuses-sdk\n android:minSdkVersion=\"14\"\n android:targetSdkVersion=\"23\" /\u003e\n```\n\nThe manifest setting tells Google Play that your application can be installed on devices with Android\n4.0 (API level 14) and higher.\n\nIf you are using Gradle build files, the `minSdkVersion` setting in the build file\noverrides the manifest settings. \n\n```groovy\nplugins {\n id 'com.android.application'\n}\n\nandroid {\n ...\n\n defaultConfig {\n minSdkVersion 16\n ...\n }\n ...\n}\n```\n\nIn this case, the build file setting tells Google Play that the default build variant of your\napplication can be installed on devices with Android 4.1 (API level 16) and higher. For more\ninformation about build variants, see\n[Build System Overview](/studio/build).\n\n\n**Note:** If you are including several support libraries, the\nminimum SDK version must be the *highest* version required by any of\nthe specified libraries. For example, if your app includes both the [v14 Preference Support library](/topic/libraries/support-library/features#v14-preference) and the\n[v17 Leanback library](/topic/libraries/support-library/features#v17-leanback), your minimum\nSDK version must be 17 or higher."]]