Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Anda dapat memeriksa apakah Profil Startup berfungsi menggunakan Android Studio
atau melihat metadata build R8.
Mengonfirmasi dengan Android Studio
Untuk mengonfirmasi pengoptimalan tata letak DEX, gunakan Android Studio untuk membuka APK dan
memverifikasi class dalam file DEX. Pastikan classes.dex utama tidak
diisi sepenuhnya. Jika aplikasi Anda terdiri dari satu file DEX, Anda dapat memeriksa
apakah aplikasi berisi dua file DEX setelah mengaktifkan Profil Startup.
Android Studio akan memperingatkan Anda jika class startup tidak muat dalam satu file DEX.
Untuk mendapatkan informasi diagnostik yang menyertakan jumlah metode non-startup di
class startup, pastikan compiler R8 diupdate setidaknya ke versi
8.3.36-dev dengan melakukan perubahan berikut pada file settings.gradle saat
Anda menerapkan Profil Startup:
Pastikan Anda menambahkan --info setelah
assembleRelease dalam perintah berikut saat mem-build dengan Gradle.
./gradlew assembleRelease --info
Diagnostik kemudian dicetak ke terminal.
Jika aplikasi atau library Anda mereferensikan API yang di-desugar, implementasi
kompatibilitas yang dipaketkan dari class ini selalu terdapat dalam file
DEX terakhir. File DEX terakhir yang di-desugar ini tidak berpartisipasi dalam pengoptimalan
tata letak DEX.
Konfirmasi dengan metadata paket
Mulai AGP 8.8, R8 menghasilkan metadata di Android App Bundle (AAB) yang
dapat Anda gunakan untuk memeriksa apakah pengoptimalan tata letak DEX berhasil. Untuk memeriksa apakah pengoptimalan berfungsi, lakukan hal berikut:
Build AAB aplikasi Anda:
./gradlew app:bundleRelease
Pastikan ada setidaknya satu file DEX yang berisi teks
"startup": true.
Bandingkan nilai hash dengan nilai "checksum" dari langkah 1. Jika nilai SHA-256
tidak cocok, mungkin ada langkah kompilasi yang mengganggu kemampuan
R8 untuk menghasilkan file DEX.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 UTC."],[],[],null,["# Confirm Startup Profiles optimization\n\nYou can check that your Startup Profiles are working using either Android Studio\nor looking at the R8 build metadata.\n\nConfirm with Android Studio\n---------------------------\n\nTo confirm DEX layout optimization, use Android Studio to open the APK and\nverify the classes in the DEX files. Make sure the primary `classes.dex` isn't\ncompletely filled. If your app consists of a single DEX file, you can check\nwhether the app contains two DEX files after enabling the Startup Profile.\n\nAndroid Studio warns you if the startup classes don't fit in a single DEX file.\nTo get diagnostic information that includes the amount of non-startup methods in\nthe startup classes, make sure the R8 compiler is updated to at least version\n8.3.36-dev by making the following changes to the `settings.gradle` file when\nyou apply the Startup Profile: \n\n### Kotlin\n\n```kotlin\npluginManagement {\n buildscript {\n repositories {\n mavenCentral()\n maven {\n url = uri(\"https://storage.googleapis.com/r8-releases/raw\")\n }\n }\n dependencies {\n classpath(\"com.android.tools:r8:8.3.6-dev\")\n }\n }\n}\n```\n\n### Groovy\n\n```groovy\npluginManagement {\n buildscript {\n repositories {\n mavenCentral()\n maven {\n url uri('https://storage.googleapis.com/r8-releases/raw')\n }\n }\n dependencies {\n classpath 'com.android.tools:r8:8.3.6-dev\"\n }\n }\n}\n```\n\nMake sure you add `--info` after\n`assembleRelease` in the following command when building with Gradle. \n\n ./gradlew assembleRelease --info\n\nThe diagnostic is then printed to the terminal.\n\nIf your app or any libraries reference any [desugared APIs](/studio/write/java8-support#library-desugaring), the bundled\ncompatibility implementations of these classes are always contained in the last\nDEX file. This desugared last DEX file doesn't participate in DEX layout\noptimizations.\n\nConfirm with bundle metadata\n----------------------------\n\n| **Note:** This workflow has only been tested on Linux.\n\nStarting with AGP 8.8, R8 outputs metadata in your Android App Bundle (AAB) that\nyou can use to check if the DEX layout optimization was successful. To check if\nthe optimization worked, do the following:\n\n1. Build your app's AAB:\n\n ./gradlew app:bundleRelease\n\n2. Check that there's at least one DEX file that contains the text\n `\"startup\": true`.\n\n 1. Open the metadata:\n\n unzip -j -o \u003cvar translate=\"no\"\u003epath-to-aab\u003c/var\u003e BUNDLE-METADATA/com.android.tools/r8.json && jq .dexFiles r8.json\n\n The path to your AAB might be something like\n `app/build/outputs/bundle/release/app-release.aab`.\n 2. Check the output, which should look something like this:\n\n inflating: r8.json\n [\n {\n \"checksum\": \"f0b4b0ddb295812607f44efe03cf7a830056ccfddbdb81db3760d2281940e951\",\n \"startup\": true\n }\n ]\n\n If you only see `\"startup\": false` in the metadata, you need to\n [enable startup profiles](/topic/performance/baselineprofiles/dex-layout-optimizations#create-startup) and ensure that your startup\n profile isn't obfuscated.\n3. Check that the SHA-256 values from the metadata match those from the AAB. To\n get the SHA-256 values for all your DEX files run the following:\n\n unzip -o \u003cvar translate=\"no\"\u003epath-to-aab\u003c/var\u003e */dex/*.dex && sha256sum */dex/*\n\n The output should look something like this: \n\n Archive: app/build/outputs/bundle/release/myapp-release.aab\n inflating: base/dex/classes.dex\n f0b4b0ddb295812607f44efe03cf7a830056ccfddbdb81db3760d2281940e951 base/dex/classes.dex\n\n Compare the hash values to the \"checksum\" values from step 1. If the SHA-256\n values don't match, there might be a compilation step interfering with R8's\n ability to output DEX files."]]