با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این صفحه به شما نشان می دهد که چگونه NDK را در پروژه خود با توجه به نسخه پلاگین Android Gradle (AGP) مورد استفاده پروژه پیکربندی کنید.
مراحل با توجه به نسخه AGP مورد استفاده در پروژه متفاوت است. نسخه Android Gradle Plugin را در یکی از مکان های زیر پیدا کنید:
فایل > ساختار پروژه > منوی پروژه در اندروید استودیو
فایل build.gradle سطح بالا در پروژه
نسخه زیر را انتخاب کنید:
AGP نسخه 4.1+
برای پیکربندی NDK گزینه های زیر را دارید:
(توصیه می شود) از ویژگی ndkVersion برای تنظیم نسخه NDK استفاده کنید.
هیچ خاصیتی را تنظیم نکنید. Android Studio به طور خودکار نسخه پیش فرض NDK را برای آن نسخه AGP خاص (در این مورد، NDK نسخه 21.0.6113669) دانلود می کند یا می توانید NDK را از خط فرمان نصب کنید . Android Studio تمام نسخه های NDK را در فهرست راهنمای android-sdk /ndk/ نصب می کند. هر نسخه در یک زیر شاخه با شماره نسخه به عنوان نام آن قرار دارد.
برای موارد استفاده خاص، از ویژگی ndkPath استفاده کنید:
شیار
android{ndkPath"/Users/ndkPath/ndk21"// Point to your own NDK}
کاتلین
android{ndkPath="/Users/ndkPath/ndk21"// Point to your own NDK}
NDK را از خط فرمان نصب کنید
برای نصب NDK از خط فرمان، موارد زیر را انجام دهید:
از ابزار sdkmanager برای مشاهده نسخه های بسته های CMake و NDK که در دسترس هستند استفاده کنید. مشابه سایر اجزای SDK، NDK از طریق کانال های مختلف منتشر می شود:
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Configure the NDK for the Android Gradle plugin\n\nThis page shows you how to configure the NDK in your project according to the\nversion of the Android Gradle Plugin (AGP) used by the project.\n| **Note:** If possible, you should try to update the version of AGP in your project to version 4.1 or later. These AGP versions will auto-download the NDK for you in Android Studio.\n\nThe steps vary according to the version of AGP used in the project. Find the\nAndroid Gradle Plugin version in either of the following locations:\n\n- **File \\\u003e Project Structure \\\u003e Project** menu in Android Studio\n- The top-level `build.gradle` file in the project\n\nSelect the version below: \nAGP 4.1+ AGP 4.0 AGP 3.6 AGP 3.5 AGP 3.4\n\nAGP version 4.1+\n----------------\n\nYou have the following options to configure the NDK:\n\n- (Recommended) Use the [`ndkVersion`](/studio/projects/install-ndk#apply-specific-version) property to set the NDK version.\n- Do not set any property. Android Studio will automatically download the [default version of the NDK for that specific AGP version](/studio/projects/install-ndk#default-ndk-per-agp) (in this case, NDK version 21.0.6113669) or you can [install the NDK from the command line](#command-line). Android Studio installs all versions of the NDK in the \u003cvar translate=\"no\"\u003eandroid-sdk\u003c/var\u003e`/ndk/` directory. Each version is located in a subdirectory with the version number as its name.\n- For special use cases, use the `ndkPath` property:\n\n ### Groovy\n\n ```groovy\n android {\n ndkPath \"/Users/ndkPath/ndk21\" // Point to your own NDK\n }\n ```\n\n ### Kotlin\n\n ```kotlin\n android {\n ndkPath = \"/Users/ndkPath/ndk21\" // Point to your own NDK\n }\n ```\n | **Note:** Remove this property before distributing your source code; it should be left outside of your version control system.\n\n### Install the NDK from the command line\n\nTo install the NDK from the command line, do the following:\n\n1. Use the `sdkmanager` tool to view versions of CMake and NDK packages that\n are available. Similar to other SDK components, the NDK is released through\n different channels:\n\n ```scdoc\n sdkmanager --list [--channel=channel_id] // NDK channels: 0 (stable),\n // 1 (beta), or 3 (canary)\n ```\n2. Pass the `sdkmanager` the strings for the packages that you want to install.\n For example, to install CMake or the NDK, use the following syntax:\n\n ```transact-sql\n sdkmanager --install\n [\"ndk;\u003cvar translate=\"no\"\u003emajor\u003c/var\u003e.\u003cvar translate=\"no\"\u003eminor\u003c/var\u003e.\u003cvar translate=\"no\"\u003ebuild\u003c/var\u003e[\u003cvar translate=\"no\"\u003esuffix\u003c/var\u003e]\" | \"cmake;major.minor.micro.build\"]\n [--channel=\u003cvar translate=\"no\"\u003echannel_id\u003c/var\u003e]\n ```\n\n Use the `--channel` option to only install a package if it has been released\n in a channel *up to and including* \u003cvar translate=\"no\"\u003echannel_id.\u003c/var\u003e\n\nFor more information, see [sdkmanager](/studio/command-line/sdkmanager)."]]