- תחביר:
-
<uses-native-library android:name="string" android:required=["true" | "false"] />
- נמצא בתוך:
-
<application>
- description:
-
מציין ספריית Native משותפת שסופקה על ידי הספק שהאפליקציה צריכה להיות מקושרת אליה. האלמנט הזה אומר למערכת לאפשר גישה לספרייה המקורית עבור החבילה.
ספריות 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 31
- ראו גם:
<uses-native-library>
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. 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,["# <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)"]]