- składnia:
-
<uses-native-library android:name="string" android:required=["true" | "false"] />
- zawarte w:
-
<application>
- description:
-
Określa udostępnioną przez dostawcę bibliotekę natywną, z którą aplikacja musi być połączona. Ten element informuje system, że biblioteka natywna jest dostępna dla pakietu.
Biblioteki NDK są domyślnie dostępne, dlatego nie wymagają tagu
<uses-native-library>
.Natywne biblioteki współdzielone inne niż NDK, które są dostarczane przez producentów krzemu lub producentów urządzeń, nie są domyślnie dostępne, jeśli aplikacja jest przeznaczona na Androida 12 (poziom interfejsu API 31) lub nowszego. Biblioteki są dostępne tylko wtedy, gdy są wyraźnie wymagane za pomocą tagu
<uses-native-library>
.Jeśli aplikacja jest kierowana na Androida 11 (poziom API 30) lub starszego, tag
<uses-native-library>
nie jest wymagany. W takim przypadku każda natywna biblioteka udostępniona jest dostępna niezależnie od tego, czy jest biblioteką NDK.Ten element ma też wpływ na instalację aplikacji na konkretnym urządzeniu. Jeśli ten element jest obecny, a jego atrybut
android:required
ma wartośćtrue
, platformaPackageManager
nie zezwoli użytkownikowi na zainstalowanie aplikacji, chyba że biblioteka jest obecna na jego urządzeniu.Atrybut
android:required
został szczegółowo opisany w następnej sekcji. - atrybuty:
-
android:name
- Nazwa pliku biblioteki.
android:required
-
Wartość logiczna wskazująca, czy aplikacja wymaga biblioteki określonej przez
android:name
.-
"true"
: aplikacja nie działa bez tej biblioteki. System nie zezwala na instalowanie aplikacji na urządzeniach, które nie mają biblioteki. -
"false"
: aplikacja korzysta z biblioteki, jeśli jest dostępna, ale w razie potrzeby może działać bez niej. System zezwala na instalację aplikacji, nawet jeśli biblioteka nie jest obecna. Jeśli używasz"false"
, ponosisz odpowiedzialność za prawidłowe obsługiwanie braku biblioteki.
Wartość domyślna to
"true"
. -
- wprowadzony w:
- Poziom API 31
- Zobacz też:
<korzysta z biblioteki-natywnej>
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-08-21 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 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)"]]