- 構文:
-
<uses-native-library android:name="string" android:required=["true" | "false"] />
- 上位の要素:
-
<application>
- 説明:
-
アプリをリンクする必要があるベンダー提供の共有ネイティブ ライブラリを指定します。この要素はシステムに対し、パッケージからネイティブ ライブラリにアクセス可能にするよう指示します。
NDK ライブラリはデフォルトでアクセス可能であるため、
<uses-native-library>
タグは不要です。シリコン ベンダーまたはデバイス メーカーが提供する NDK 以外のネイティブ共有ライブラリは、アプリが Android 12(API レベル 31)以降をターゲットとしている場合、デフォルトではアクセスできません。
<uses-native-library>
タグを使用して明示的にリクエストした場合にのみ、ライブラリにアクセスできます。Android 11(API レベル 30)以前をターゲットとするアプリの場合、
<uses-native-library>
タグは不要です。この場合、ネイティブ共有ライブラリは、NDK ライブラリかどうかにかかわらずアクセスできます。この要素は、特定のデバイスへのアプリのインストールにも影響します。この要素が存在し、その
android:required
属性がtrue
に設定されている場合、PackageManager
フレームワークは、ライブラリがユーザーのデバイスに存在しない限り、ユーザーがアプリをインストールすることを許可しません。android:required
属性については次のセクションで詳しく説明します。 - 属性:
-
android:name
- ライブラリ ファイルの名前。
android:required
-
android:name
で指定されたライブラリがアプリにとって必須かどうかを示すブール値。-
"true"
: このライブラリがなければアプリは機能しません。このライブラリが存在しないデバイスにアプリをインストールすることはできません。 -
"false"
: アプリは、このライブラリが存在する場合はライブラリを使用しますが、必要に応じてこのライブラリがなくても機能するように設計されています。 このライブラリが存在しない場合でも、アプリをインストールできます。"false"
を使用する場合は、ライブラリが存在しないことを適切に処理する必要があります。
デフォルト値は
"true"
です。 -
- 導入時の API レベル:
- API レベル 31
- 関連項目:
<uses-native-library>
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-08-21 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-21 UTC。"],[],[],null,["# <uses-native-library\u003e\n\nsyntax:\n:\n\n ```xml\n \u003cuses-native-library\n android:name=\"string\"\n android:required=[\"true\" | \"false\"] /\u003e\n ```\n\ncontained in:\n:\n `\n `[\u003capplication\u003e](/guide/topics/manifest/application-element)`\n `\n\ndescription:\n\n:\n Specifies a [vendor-provided shared native library](https://source.android.com/devices/tech/config/namespaces_libraries#adding-additional-native-libraries)\n that the application must be linked against. This element tells the system to make the native\n library accessible for the package.\n\n\n NDK libraries are by default accessible and therefore don't require the\n `\u003cuses-native-library\u003e` tag.\n\n\n Non-NDK native shared libraries that are provided by silicon vendors or device manufacturers\n aren't accessible by default if the app targets Android 12 (API level 31) or higher. The\n libraries are accessible only when they are explicitly requested using the\n `\u003cuses-native-library\u003e` tag.\n\n\n If the app targets Android 11 (API level 30) or lower, the\n `\u003cuses-native-library\u003e` tag isn't required. In that case, any native shared\n library is accessible regardless of whether it is an NDK library.\n\n\n This element also affects the installation of the application on a particular device. If this\n element is present and its `android:required` attribute is set to\n `true`, the\n [PackageManager](/reference/android/content/pm/PackageManager)\n framework won't let a user install the application unless the library is present on the\n user's device.\n\n\n The `android:required` attribute is described in detail in the following section.\n\nattributes:\n:\n\n `android:name`\n :\n The name of the library file.\n\n `android:required`\n :\n Boolean value that indicates whether the application requires the\n library specified by `android:name`.\n\n - `\"true\"`: the application doesn't function without this library. The system doesn't let the application install on a device that doesn't have the library.\n - `\"false\"`: the application uses the library if present, but is designed to function without it if necessary. The system lets the application install, even if the library isn't present. If you use `\"false\"`, you are responsible for gracefully handling the absence of the library.\n\n\n The default is `\"true\"`.\n\n\nintroduced in:\n: API level 31\n\nsee also:\n:\n - [PackageManager](/reference/android/content/pm/PackageManager)\n - [\u003cuses-library\u003e](/guide/topics/manifest/uses-library-element)\n [](/guide/topics/manifest/uses-library-element)\n\n [](/guide/topics/manifest/uses-library-element)\n[](/guide/topics/manifest/uses-library-element)"]]