تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بعد تفعيل ميزة تحسين التطبيق، تأكَّد من أنّ تطبيقك يعمل على النحو المطلوب
وأنّ إعدادات R8 تحقّق ما تتوقّعه. في ما يلي الخطوات العامة:
اختبار تجارب المستخدمين الرئيسية (CUJ) في تطبيقك: على سبيل المثال، تأكَّد مما يلي:
يمكن للمستخدمين تسجيل الدخول وتنفيذ مهام مهمة أخرى.
قياس المكاسب في الأداء باستخدام مقاييس الأداء:قارِن أداء تطبيقك
قبل تفعيل ميزة "تحسين التطبيق" وبعد تفعيلها.
إذا واجهت مشاكل، يوفّر R8 أدوات لمساعدتك في تحديد المشاكل وحلّها. إذا لم تتمكّن
من حلّ مشكلة في R8، يمكنك إبلاغنا بخطأ.
نصائح عامة
غالبًا ما تكون المشاكل المتعلّقة بـ R8 فريدة لتطبيقك، ولكن إليك بعض النصائح العامة ل
تسهيل تصحيح الأخطاء:
إيقاف التشويش مؤقتًا: يعمل R8 على تشويش الرموز البرمجية كجزء من عملية
التحسين. لا يتسبب التشويش عادةً في حدوث أخطاء، ولكنه
يجعل تصحيح الأخطاء أكثر صعوبة. أضِف علامتَي الترميز
‑dontobfuscate و‑dontoptimize
إلى ملف قواعد الاحتفاظ لمساعدتك في تحديد الرمز البرمجي الذي يتسبب في حدوث المشكلة.
التحقّق من الانعكاس: إذا واجهت استثناء ما مِن عنصر مماثل، مثل
Caused by: java.util.NoSuchElementException: Collection contains no element
matching the predicate in the stack trace ،
يشير الاستثناء عادةً إلى أنّ الحقل المعنيّ يتم استخدامه من خلال
الاستكشاف وعليك إضافة قاعدة الاحتفاظ.
فحص الرمز الثنائي: تتطلّب معظم مشاكل R8 فحص الرمز الثنائي، وهو ما
يمكنك تنفيذه باستخدام أدوات مثل أداة تحليل APK.
التحقّق من القواعد التي يتم تطبيقها
لعرض تقرير كامل عن جميع القواعد التي تطبّقها أداة R8 عند إنشاء
مشروعك، أدرِج ما يلي في ملف proguard‑rules.pro الخاص بوحدة تطبيقك:
يمكنك تحديد أي مسار واسم ملف. في حال عدم تحديد مسار أو اسم ملف،يُخرج R8 تقرير القواعد في <module-name>/build/outputs/mapping/<build-type>/configuration.txt.
فهم سبب الاحتفاظ بالرمز
إذا ظهرت لك رموز تم الاحتفاظ بها كنت تتوقع إزالتها، استخدِم خيار الإعداد
‑whyareyoukeeping للمساعدة في فهم سبب
الاحتفاظ بها. تُخرج أداة R8 مسارًا من الرمز المحفوظ إلى إحدى نقاط
الدخول في تطبيقك. لمزيد من المعلومات، يُرجى الاطّلاع على مستندات
‑whyareyoukeeping
في دليل Proguard.
استرداد تسلسل استدعاء الدوال البرمجية الأصلي
يتم تغيير الرمز الذي يعالجه R8 بطرق مختلفة لكي لا يشير تتبع تسلسل استدعاء الدوال البرمجية مجددًا إلى الرمز الأصلي. على سبيل المثال، يمكن أن تتغيّر أرقام الأسطر وأسماء
الفئات والطُرق. لاسترداد تتبع تسلسل استدعاء الدوال البرمجية الأصلي، يقدّم R8 أداة سطر الأوامر
retrace، والتي تكون مضمّنة في حزمة
أدوات سطر الأوامر.
لاستخدام ميزة "تتبُّع تسلسل استدعاء الدوال البرمجية"، عليك تزويدها بملف تعيين وملف تتبُّع تسلسل استدعاء الدوال البرمجية. يتم تجميع ملف الربط
، الذي يُسمى mapping.txt، تلقائيًا مع "حِزمة تطبيق Android
" (AAB). لمزيد من التفاصيل، يُرجى الاطّلاع على مستندات إعادة التتبّع ومقالة "مركز مساعدة 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,["# Test and troubleshoot the optimization\n\nAfter you enable app optimization, check that your app is working as intended\nand that the R8 configuration is doing what you expect. The general steps are as\nfollows:\n\n1. **Test your app's critical user journeys (CUJs):** For example, make sure that users can sign in and do other important tasks.\n2. **Measure performance gains using benchmarks:** [Benchmark your app](/topic/performance/benchmarking/benchmarking-overview) before and after enabling app optimization.\n\nIf you find issues, R8 provides tools to help you troubleshoot. If you're unable\nto solve an issue with R8, [file a bug](https://b.corp.google.com/issues/new?component=326788&template=1025938&pli=1).\n\nGeneral tips\n------------\n\nIssues with R8 are often unique to your app, but here are some general tips to\nmake debugging easier:\n\n- **Temporarily turn off obfuscation:** R8 obfuscates code as part of its optimization process. Obfuscation usually isn't the cause of errors, but obfuscation makes errors more difficult to debug. Add the `‑dontobfuscate` and `‑dontoptimize` flags to the keep rules file to help you pinpoint problematic code.\n- **Check for reflection:** If you run into a *no such element* exception such\n as\n\n `Caused by: java.util.NoSuchElementException: Collection contains no element\n matching the predicate in the stack trace` ,\n\n the exception usually means the field in question is being used through\n reflection and you have to add a keep rule.\n- **Inspect bytecode:** Most R8 issues require bytecode inspection, which you\n can do with tools such as the [APK Analyzer](/studio/debug/apk-analyzer).\n\nCheck which rules are applied\n-----------------------------\n\nTo output a full report of all the rules that R8 applies when building your\nproject, include the following in your app's module\n`proguard‑rules.pro` file: \n\n -printconfiguration \u003coutput-dir\u003e/\u003creport-name\u003e.txt\n\nYou can specify any path and filename. If you don't specify a path or filename,\nR8 outputs the rules report at `\u003cmodule-name\u003e/build/outputs/mapping/\u003cbuild-type\u003e/configuration.txt`.\n\nUnderstand why code was kept\n----------------------------\n\nIf you see kept code that you expected to be removed, use the configuration\noption `‑whyareyoukeeping` to help understand why the code was\nkept. R8 outputs a path from the kept code to one of your app's [entry\npoints](/topic/performance/app-optimization/add-keep-rules#how-write). For more information, see the\n[`‑whyareyoukeeping`](https://www.guardsquare.com/manual/configuration/usage)\ndocumentation in the Proguard manual.\n\nRecover the original stack trace\n--------------------------------\n\nCode processed by R8 is changed in various ways so that the stack trace no\nlonger refers to the original code. For example, line numbers and the names of\nclasses and methods can change. To recover the original stack trace, R8 provides\nthe retrace command-line tool, which is bundled with the command-line tools\npackage.\n\nTo use retrace, give it a *mapping file* and a stack trace file. The mapping\nfile, called `mapping.txt`, is automatically bundled with your Android App\nBundle (AAB). For more details, see the [retrace](/studio/command-line/retrace) documentation and the Play\nConsole Help Center article about how to [de‑obfuscate crash stack\ntraces](https://support.google.com/googleplay/android-developer/answer/9848633).\n| **Warning:** If you're shipping APKs, the `mapping.txt` file isn't automatically bundled with your APK. Android Studio saves the mapping file in the `/build/outputs/mapping/` directory. The mapping file is overwritten every time you build your project, so you must save a copy each time you publish a new release."]]