- نحو:
<uses-native-library android:name="string" android:required=["true" | "false"] />
- موجود در:
-
<application>
- توضیحات:
یک کتابخانه بومی مشترک ارائه شده توسط فروشنده را مشخص می کند که برنامه باید با آن پیوند داده شود. این عنصر به سیستم می گوید که کتابخانه بومی را برای بسته قابل دسترس کند.
کتابخانه های NDK به طور پیش فرض قابل دسترسی هستند و بنابراین به تگ
<uses-native-library>
نیاز ندارند.اگر برنامه Android 12 (سطح API 31) یا بالاتر را هدف قرار دهد، کتابخانههای مشترک بومی غیر NDK که توسط فروشندگان سیلیکون یا سازندگان دستگاه ارائه میشوند، بهطور پیشفرض در دسترس نیستند. کتابخانه ها تنها زمانی قابل دسترسی هستند که به طور صریح با استفاده از تگ
<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 31
- همچنین ببینید:
<uses-native-library>
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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 بهوقت ساعت هماهنگ جهانی."],[],[],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)"]]