- Sintaxe:
-
<uses-native-library android:name="string" android:required=["true" | "false"] />
- contido em:
-
<application>
- descrição:
-
Especifica uma biblioteca nativa compartilhada pelo fornecedor que precisa ser vinculada ao aplicativo. Esse elemento instrui o sistema a tornar a biblioteca nativa acessível ao pacote.
As bibliotecas do NDK podem ser acessadas por padrão e não exigem a tag
<uses-native-library>
.As bibliotecas compartilhadas nativas que não são do NDK e são oferecidas por fornecedores de componentes eletrônicos ou de dispositivos não podem ser acessadas por padrão se o app for direcionado ao Android 12 (nível 31 da API) ou versões mais recentes. As bibliotecas só podem ser acessadas quando forem explicitamente solicitadas usando a tag
<uses-native-library>
.Se o app for direcionado ao Android 11 (API de nível 30) ou versões anteriores, a tag
<uses-native-library>
não é necessária. Nesse caso, qualquer biblioteca compartilhada nativa pode ser acessada independente de ser uma biblioteca do NDK ou não.Esse elemento também afeta a instalação do aplicativo em certos dispositivos. Se este elemento estiver presente e o atributo
android:required
estiver definido comotrue
, o framework dePackageManager
não vai permitir que o usuário instale o aplicativo, a menos que a biblioteca esteja presente no dispositivo do usuário.O atributo
android:required
é descrito em detalhes na próxima seção. - atributos:
-
android:name
- O nome do arquivo da biblioteca.
android:required
-
Valor booleano que indica se o aplicativo exige a
biblioteca especificada por
android:name
:-
"true"
: o aplicativo não funciona sem essa biblioteca. O sistema não permite que o aplicativo seja instalado em um dispositivo que não tenha a biblioteca. -
"false"
: o aplicativo usa a biblioteca se ela estiver presente, mas foi criado para funcionar sem ela, se necessário. O sistema permite que o aplicativo seja instalado, mesmo que a biblioteca não esteja disponível. Se usar"false"
, você será responsável por lidar com a ausência da biblioteca de maneira prática.
O padrão é
"true"
. -
- introduzido no:
- Nível 31 da API
- confira também:
<uses-native-library>
O conteúdo e os exemplos de código nesta página estão sujeitos às licenças descritas na Licença de conteúdo. Java e OpenJDK são marcas registradas da Oracle e/ou suas afiliadas.
Última atualização 2025-08-21 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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)"]]