حزمة ndk
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتيح لك أداة ndk-stack
ترميز عمليات تتبُّع تسلسل استدعاء الدوال البرمجية من
adb logcat
أو
شهد ضريح في /data/tombstones/
. يستبدل أي عنوان داخل مكتبة مشتركة بالاسم <source-file>:<line-number>
المقابل من رمز المصدر، ما يجعل تصحيح الأخطاء أسهل.
على سبيل المثال، تترجم العبارة التالية:
I/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 31): Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'
I/DEBUG ( 31): pid: 351, tid: 351 >>> /data/local/ndk-tests/crasher <<<
I/DEBUG ( 31): signal 11 (SIGSEGV), fault addr 0d9f00d8
I/DEBUG ( 31): r0 0000af88 r1 0000a008 r2 baadf00d r3 0d9f00d8
I/DEBUG ( 31): r4 00000004 r5 0000a008 r6 0000af88 r7 00013c44
I/DEBUG ( 31): r8 00000000 r9 00000000 10 00000000 fp 00000000
I/DEBUG ( 31): ip 0000959c sp be956cc8 lr 00008403 pc 0000841e cpsr 60000030
I/DEBUG ( 31): #00 pc 0000841e /data/local/ndk-tests/crasher
I/DEBUG ( 31): #01 pc 000083fe /data/local/ndk-tests/crasher
I/DEBUG ( 31): #02 pc 000083f6 /data/local/ndk-tests/crasher
I/DEBUG ( 31): #03 pc 000191ac /system/lib/libc.so
I/DEBUG ( 31): #04 pc 000083ea /data/local/ndk-tests/crasher
I/DEBUG ( 31): #05 pc 00008458 /data/local/ndk-tests/crasher
I/DEBUG ( 31): #06 pc 0000d362 /system/lib/libc.so
I/DEBUG ( 31):
إلى محتوى أكثر سهولة في القراءة:
********** Crash dump: **********
Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'
pid: 351, tid: 351 >>> /data/local/ndk-tests/crasher <<<
signal 11 (SIGSEGV), fault addr 0d9f00d8
Stack frame #00 pc 0000841e /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13
Stack frame #01 pc 000083fe /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5
Stack frame #02 pc 000083f6 /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9
Stack frame #03 pc 000191ac /system/lib/libc.so
Stack frame #04 pc 000083ea /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14
Stack frame #05 pc 00008458 /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19
Stack frame #06 pc 0000d362 /system/lib/libc.so
الاستخدام
لاستخدام ndk-stack
، تحتاج أولاً إلى دليل يحتوي على إصدارات لم تتم إزالة البيانات غير الضرورية منها من مكتبات
تطبيقك المشتركة. إذا كنت تستخدم ndk-build
، يمكنك العثور على مكتبات ملف APK المشترَكة غير المُعرَّاة في $PROJECT_PATH/obj/local/<abi>
، حيث يكون <abi>
هو ABI لجهازك.
بالنسبة إلى عملية إنشاء مكوّن إضافي لنظام Gradle المتوافق مع Android (AGP)، ستكون المكتبات التي لم تتم إزالتها في directory
<project-path>/build/intermediates/cxx/<build-type>/<hash>/obj/<abi>
، حيث يكون
<project-path>
هو دليل مشروع AGP الذي يحتوي على الوحدة
التي تحاول ترميزها (يكون هذا تلقائيًا هو app
)، و<build-type>
هو اسم
نوع التصميم CMake أو ndk-build (مثل RelWithDebInfo
أو Release
أو
Debug
أو غير ذلك). <hash>
هو رقم عشوائي، و<abi>
هو معرّف ABI لجهازك.
هناك طريقتان لاستخدام الأداة. يمكنك إرسال نص logcat كإدخال مباشر إلى البرنامج.
مثلاً:
adb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi-v7a
يمكنك أيضًا استخدام الخيار -dump
لتحديد سجلّ Logcat كملف إدخال. مثلاً:
adb logcat > /tmp/foo.txt
$NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi-v7a -dump foo.txt
عند بدء تحليل إخراج logcat، تبحث الأداة عن سطر أولي من العلامات النجمية.
مثلاً:
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
ملاحظة: عند نسخ عمليات التتبّع أو لصقها، لا تنسَ هذا السطر، وإلا لن تعمل ndk-stack
بشكل صحيح.
مزيد من المعلومات
يستخدم Google Play أداة ndk-stack
لترميز عمليات تتبُّع تسلسل استدعاء الدوال البرمجية للتطبيقات
الأصلية في Google Play Console. للحصول على معلومات عن كيفية تفعيل هذه الميزة لتطبيقك في بيئة الإنتاج، اطّلِع على كيفية تضمين ملف رموز تصحيح أخطاء أصلية لتطبيقك في Google Play Console.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-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-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# ndk-stack\n\nThe `ndk-stack` tool allows you to symbolize stack traces from\n[`adb logcat`](/tools/help/logcat) or a\ntombstone in `/data/tombstones/`. It replaces any\naddress inside a shared library with the corresponding\n`\u003csource-file\u003e:\u003cline-number\u003e` from your source code,\nmaking debugging easier.\n\nFor example, it translates something like: \n\n```\nI/DEBUG ( 31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\nI/DEBUG ( 31): Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'\nI/DEBUG ( 31): pid: 351, tid: 351 \u003e\u003e\u003e /data/local/ndk-tests/crasher \u003c\u003c\u003c\nI/DEBUG ( 31): signal 11 (SIGSEGV), fault addr 0d9f00d8\nI/DEBUG ( 31): r0 0000af88 r1 0000a008 r2 baadf00d r3 0d9f00d8\nI/DEBUG ( 31): r4 00000004 r5 0000a008 r6 0000af88 r7 00013c44\nI/DEBUG ( 31): r8 00000000 r9 00000000 10 00000000 fp 00000000\nI/DEBUG ( 31): ip 0000959c sp be956cc8 lr 00008403 pc 0000841e cpsr 60000030\nI/DEBUG ( 31): #00 pc 0000841e /data/local/ndk-tests/crasher\nI/DEBUG ( 31): #01 pc 000083fe /data/local/ndk-tests/crasher\nI/DEBUG ( 31): #02 pc 000083f6 /data/local/ndk-tests/crasher\nI/DEBUG ( 31): #03 pc 000191ac /system/lib/libc.so\nI/DEBUG ( 31): #04 pc 000083ea /data/local/ndk-tests/crasher\nI/DEBUG ( 31): #05 pc 00008458 /data/local/ndk-tests/crasher\nI/DEBUG ( 31): #06 pc 0000d362 /system/lib/libc.so\nI/DEBUG ( 31):\n```\n\ninto the more readable: \n\n```\n********** Crash dump: **********\nBuild fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'\npid: 351, tid: 351 \u003e\u003e\u003e /data/local/ndk-tests/crasher \u003c\u003c\u003c\nsignal 11 (SIGSEGV), fault addr 0d9f00d8\nStack frame #00 pc 0000841e /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13\nStack frame #01 pc 000083fe /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5\nStack frame #02 pc 000083f6 /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9\nStack frame #03 pc 000191ac /system/lib/libc.so\nStack frame #04 pc 000083ea /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14\nStack frame #05 pc 00008458 /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19\nStack frame #06 pc 0000d362 /system/lib/libc.so\n```\n\nUsage\n-----\n\nTo use `ndk-stack`, you first need a directory containing unstripped versions of\nyour app's shared libraries. If you use `ndk-build`, these unstripped shared\nlibraries are found in `$PROJECT_PATH/obj/local/\u003cabi\u003e`, where `\u003cabi\u003e` is your\ndevice's ABI.\n\nFor an Android Gradle Plugin (AGP) build, the unstripped libraries will be in\n`\u003cproject-path\u003e/build/intermediates/cxx/\u003cbuild-type\u003e/\u003chash\u003e/obj/\u003cabi\u003e`, where\n`\u003cproject-path\u003e` is the directory of the AGP project that contains the module\nyou're trying to symbolize (by default this is `app`), `\u003cbuild-type\u003e` is the\nname of the CMake or ndk-build build type (such as `RelWithDebInfo`, `Release`,\n`Debug`, etc.), `\u003chash\u003e` is arbitrary, and `\u003cabi\u003e` is your device's ABI.\n\nThere are two ways to use the tool. You can feed the logcat text as direct input to the program.\nFor example: \n\n```\nadb logcat | $NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi-v7a\n```\n\nYou can also use the `-dump` option to specify the logcat as an input file. For example: \n\n```\nadb logcat \u003e /tmp/foo.txt\n$NDK/ndk-stack -sym $PROJECT_PATH/obj/local/armeabi-v7a -dump foo.txt\n```\n\nWhen it begins parsing the logcat output, the tool looks for an initial line of asterisks.\nFor example: \n\n```\n*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n```\n\n**Note:** When copy/pasting traces, don't forget this line, or\n`ndk-stack` won't work correctly.\n\nMore information\n----------------\n\nGoogle Play uses `ndk-stack` to symbolize stack traces for native\napps in the Google Play Console. For information on how to enable this for your\napp in a production environment, see how to\n[include a native debug symbols file](/studio/build/shrink-code#strip-native-libraries)\nfor your app in the Google Play Console."]]