サポート ライブラリのセットアップ
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
注: Android 9.0(API レベル 28)のリリース以降、Jetpack の一部として AndroidX という新しいバージョンのサポート ライブラリが導入されました。AndroidX ライブラリには既存のサポート ライブラリのほか、最新の Jetpack コンポーネントも含まれています。
サポート ライブラリは引き続きご利用いただけます。過去のアーティファクト(バージョン 27 以前で android.support.*
としてパッケージ化されたもの)は、Google Maven で引き続き利用できます。ただし、新しいライブラリ開発はすべて AndroidX ライブラリ内で行うことになります。
すべての新しいプロジェクトに AndroidX ライブラリを使用することをおすすめします。また、既存のプロジェクトを AndroidX に移行することもご検討ください。
開発プロジェクトで Android サポート ライブラリをセットアップする方法は、使用する機能と、アプリでサポートする Android プラットフォーム バージョンの範囲によって異なります。
このドキュメントでは、Support Library パッケージをダウンロードして、開発環境にライブラリを追加する手順について説明します。
サポート ライブラリは、Google の Maven リポジトリから入手できるようになりました。現在、SDK Manager を使用したライブラリのダウンロードはサポートされておらず、この機能はまもなく削除されます。
サポート ライブラリの選択
サポート ライブラリをアプリに追加する前に、アプリに含める機能と、サポートする最小 Android バージョンを決定します。さまざまなライブラリによって提供される機能の詳細については、サポート ライブラリの機能をご覧ください。
Support Library の追加
Support Library を使用するには、開発環境内でアプリ プロジェクトのクラスパス依存関係を変更する必要があります。使用する Support Library ごとにこの手順を行ってください。
アプリのプロジェクトにサポート ライブラリを追加するには:
- Google の Maven リポジトリをプロジェクトの
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'
// }
}
}
- サポート ライブラリを使用するモジュールごとに、ライブラリをモジュールの
build.gradle
ファイルの dependencies
ブロックに追加します。たとえば、v4 core-utils ライブラリを追加するには、以下の行を追加します。dependencies {
...
implementation "com.android.support:support-core-utils:28.0.0"
}
注意: 動的依存関係(palette-v7:23.0.+
など)を使用すると、予期しないバージョン アップデートが生じたり、不具合によって互換性が失われたりする可能性があります。ライブラリのバージョン(palette-v7:28.0.0
など)を明示的に指定することをおすすめします。
Support Library API の使用
既存のフレームワーク API のサポートを提供する Support Library クラスには、通常はフレームワーク クラスと同じ名前が付いていますが、android.support
クラス パッケージに配置されていたり、末尾に *Compat
が付いていたりします。
注意: Support Library のクラスを使用するときは、必ず適切なパッケージからクラスをインポートしてください。たとえば、ActionBar
クラスを適用する場合は次のとおりです。
- サポート ライブラリを使用する場合:
android.support.v7.app.ActionBar
- API レベル 11 以降だけを対象に開発する場合:
android.app.ActionBar
注: サポート ライブラリをアプリ プロジェクトに組み込んだ後は、リリースに向けて、アプリを圧縮、難読化、最適化することを強くおすすめします。難読化によってソースコードを保護するだけでなく、圧縮することで、アプリに含まれるライブラリから不要なクラスが削除され、アプリのダウンロード サイズを可能な限り抑えることができます。
サポート ライブラリ機能の使用方法については、Android デベロッパーのトレーニング クラス、ガイド、サンプルをご覧ください。サポート ライブラリの個々のクラスやメソッドについては、API リファレンスの android.support
パッケージをご覧ください。
マニフェストの宣言の変更
サポート ライブラリを使用して、既存アプリの下位互換性を以前のバージョンの Android API にまで広げる場合は、必ずアプリのマニフェストを更新してください。具体的には、マニフェストの
<uses-sdk>
タグの android:minSdkVersion
要素を、新しい下位のバージョン番号に更新する必要があります。以下をご覧ください。
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="23" />
このマニフェスト設定は、アプリが Android 4.0(API レベル 14)以降を搭載するデバイスにインストール可能であることを Google Play に示します。
Gradle ビルドファイルを使用する場合は、ビルドファイルの minSdkVersion
設定がマニフェスト設定をオーバーライドします。
plugins {
id 'com.android.application'
}
android {
...
defaultConfig {
minSdkVersion 16
...
}
...
}
この例のビルドファイルの設定は、アプリのデフォルトのビルド バリアントが Android 4.1(API レベル 16)以降を搭載するデバイスにインストール可能であることを Google Play に示します。ビルド バリアントの詳細については、ビルドシステムの概要をご覧ください。
注: 複数のサポート ライブラリを追加する場合は、指定したライブラリで必要となる最新の SDK バージョンを最小 SDK バージョンとして設定する必要があります。たとえば、v14 preference サポート ライブラリと v17 Leanback ライブラリの両方をアプリに組み込んでいる場合は、最小 SDK バージョンを 17 以上にする必要があります。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-08-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 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."]]