시작 프로필은 기준 프로필의 하위 집합입니다. 시작 프로필은 빌드 시스템에서 APK의 DEX 파일에 있는 코드의 레이아웃을 개선하여 포함된 클래스와 메서드를 추가로 최적화하는 데 사용됩니다. 시작 프로필을 사용하면 앱 시작이 일반적으로 기준 프로필만 사용하는 경우보다 15~30% 더 빨라집니다.
그림 1. DEX 레이아웃 최적화로 인한 코드 위치 개선
요구사항
다음 도구와 함께 시작 프로필을 사용하는 것이 좋습니다.
Jetpack Macrobenchmark 1.2.0 이상
Android Gradle 플러그인 8.2 이상
Android 스튜디오 Iguana 이상
또한 앱에 다음 설정이 필요합니다.
R8 사용 설정됨 출시 빌드의 경우 isMinifyEnabled = true을 설정합니다.
DEX 레이아웃 최적화가 사용 설정되었습니다. 앱 모듈의 빌드 파일의 baselineProfile {} 블록에서 dexLayoutOptimization = true을 설정합니다.
시작 프로필 만들기
기본 기준 프로필 생성기 템플릿을 사용하면 Android 스튜디오에서 기준 프로필과 함께 시작 프로필을 만듭니다.
시작 프로필을 만드는 기본 방법은 Android 스튜디오 내에서 기준 프로필 생성기 모듈 템플릿을 사용하는 것입니다. 여기에는 기본 시작 프로필을 형성하는 시작 상호작용이 포함됩니다. 중요한 사용자 여정 (CUJ)을 더 추가하여 이 시작 프로필을 보강하려면 includeInStartupProfile이 true로 설정된 rule 블록에 앱 시작 CUJ를 추가하세요. 간단한 앱의 경우 앱의 MainActivity를 실행하는 것으로 충분할 수 있습니다. 더 복잡한 앱의 경우 홈 화면에서 앱을 시작하거나 딥 링크로 실행하는 등 앱의 가장 일반적인 진입점을 추가하는 것이 좋습니다.
다음 코드 스니펫은 홈 화면에서 앱을 시작하고 딥 링크로 실행하는 것을 포함하는 기준 프로필 생성기 (기본적으로 BaselineProfileGenerator.kt 파일)를 보여줍니다. 딥 링크는 앱의 홈 화면이 아닌 앱의 뉴스 피드로 바로 연결됩니다.
@RunWith(AndroidJUnit4::class)@LargeTestclassBaselineProfileGenerator{@get:Rulevalrule=BaselineProfileRule()@Testfungenerate(){rule.collect(packageName="com.example.app",includeInStartupProfile=true){// Launch directly into the NEWS_FEED.startActivityAndWait(Intent().apply{setPackage(packageName)setAction("com.example.app.NEWS_FEED")})}}}
앱의 기준 프로필 생성 구성을 실행하고 src/<variant>/generated/baselineProfiles/startup-prof.txt에서 시작 프로필 규칙을 찾습니다.
스타트업 프로필 생성 시 고려사항
시작 프로필을 만들 때 어떤 사용자 여정을 다룰지 결정하려면 대부분의 사용자가 애플리케이션을 시작하는 위치를 고려하세요. 일반적으로 런처에서 로그인한 후입니다. 이것이 가장 기본적인 기준 프로필 여정입니다.
첫 번째 사용 사례를 다룬 후 앱 시작에 관한 사용자 유입경로를 따릅니다. 대부분의 경우 앱 시작 유입경로는 다음 목록을 따릅니다.
기본 런처 활동
앱 시작을 트리거하는 알림
선택적 런처 활동
이 목록을 위에서부터 작업하고 classes.dex가 가득 차기 전에 중지합니다. 나중에 더 많은 여정을 다루려면 시작 경로에서 코드를 이동하고 여정을 더 추가하세요.
시작 경로에서 코드를 이동하려면 앱 시작 중에 Perfetto 트레이스를 검사하고 오래 실행되는 작업을 찾습니다. 메서드 추적이 사용 설정된macrobenchmark를 사용하여 앱 시작 중에 메서드 호출을 자동화하고 완전하게 확인할 수도 있습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-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-07-27(UTC)"],[],[],null,["# Create Startup Profiles\n\nStartup Profiles are a subset of Baseline Profiles. Startup Profiles are used\nby the build system to further optimize the classes and methods they contain\nby improving the layout of code in your APK's DEX files. With Startup Profiles,\nyour app startup is usually between 15% and 30% faster than with Baseline\nProfiles alone.\n| **Note:** Startup Profiles impact your app's APK size, and the performance impact they provide might be large or small depending on how your app is structured. We recommend running an A/B test to assess the effect of Startup Profiles on your app.\n**Figure 1.** Code locality improvement from DEX layout optimization.\n\nRequirements\n------------\n\nWe recommend using Startup Profiles with the following tools:\n\n- Jetpack Macrobenchmark 1.2.0 or higher\n- Android Gradle Plugin 8.2 or higher\n- Android Studio Iguana or higher\n\nIn addition, you need the following settings in your app:\n\n- [R8](/build/shrink-code) enabled. For your release build, set `isMinifyEnabled = true`.\n- DEX layout optimizations enabled. In the `baselineProfile {}` block of the app module's build file, set `dexLayoutOptimization = true`.\n\nCreate a Startup Profile\n------------------------\n\n| **Note:** Unlike regular Baseline Profiles, Startup Profiles can't be contributed by libraries; Startup Profiles only include rules generated by the startup tests that you define, so make sure that you include all the main ways that users can enter your app.\n| **Note:** AGP 8.2 doesn't support distinct Startup Profiles per variant. If you're using AGP 8.2, use Baseline Profile Gradle plugin 1.2.3 or higher to automatically merge across variants. Upgrade to AGP 8.3 to use distinct Startup Profiles per variant.\n\nAndroid Studio creates a Startup Profile alongside a Baseline Profile when you\nuse the default Baseline Profile Generator template.\n\nThe general steps to create and generate a Startup Profile are the same as those\nto [create a Baseline Profile](/topic/performance/baselineprofiles/create-baselineprofile).\n\nThe default way to create a Startup Profile is by using the Baseline Profile\nGenerator module template from within Android Studio. This includes startup\ninteractions that form a basic Startup Profile. To augment this Startup Profile\nwith more Critical User Journeys (CUJs), add your app startup CUJs to a `rule`\nblock with `includeInStartupProfile` set to `true`. For simple apps, launching\nthe app's `MainActivity` might be sufficient. For more complex apps, consider\nadding the most common entry points into your app, such as starting the app from\nthe home screen or launching into a [deep link](/training/app-links/deep-linking).\n\nThe following code snippet shows a Baseline Profile generator (by default the\n`BaselineProfileGenerator.kt` file) that includes starting your app from the\nhome screen and launching into a deep link. The deep link goes directly to the\napp's news feed, not the app's home screen. \n\n @RunWith(AndroidJUnit4::class)\n @LargeTest\n class BaselineProfileGenerator {\n\n @get:Rule\n val rule = BaselineProfileRule()\n\n @Test\n fun generate() {\n rule.collect(\n packageName = \"com.example.app\",\n includeInStartupProfile = true\n ) {\n // Launch directly into the NEWS_FEED.\n startActivityAndWait(Intent().apply {\n setPackage(packageName)\n setAction(\"com.example.app.NEWS_FEED\")\n })\n }\n }\n }\n\nRun the [**Generate Baseline Profile for app** configuration](/topic/performance/baselineprofiles/create-baselineprofile#generate-profile) and find the\nStartup Profile rules at\n`src/\u003cvariant\u003e/generated/baselineProfiles/startup-prof.txt`.\n\nConsiderations to creating startup profiles\n-------------------------------------------\n\n| **Tip:** For the most performance improvement, try to limit the user journeys added to your startup profile so that you stay within one DEX file.\n| **Note:** To get the highest impact performance improvement from startup profile, the startup code should fit into the `classes.dex` file, which is the first DEX file. If that's not possible, the startup code will overflow into the next DEX files, which are then filled up with other classes and methods. See [Confirm Startup Profiles optimization](/topic/performance/baselineprofiles/confirm-startup-profiles) to find out if this happens, and what you can do to reduce your app's startup size to make it start faster.\n\nTo decide which user journeys to cover when creating a startup profile, consider\nwhere most users start the application. Usually that is from the launcher and\nafter they have been logged in. This is also the most basic baseline profile\njourney.\n\nAfter the first use case has been covered, follow the user funnel for app\nstartup. In many cases, app startup funnels follow this list:\n\n1. Main launcher activity\n2. Notifications that trigger app startup\n3. Optional launcher activities\n\nWork this list from the top and stop before classes.dex is full. To cover\nmore journeys afterwards, move code out of the startup path and add more\njourneys.\nTo move code out of the startup path, inspect Perfetto traces during app startup\nand look for long running operations. You can also use a [macrobenchmark](/topic/performance/benchmarking/macrobenchmark-overview)\nwith [method tracing enabled](/topic/performance/benchmarking/macrobenchmark-instrumentation-args#profiling-mode)\nfor an automatable and complete view of method calls during app startup.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Create Baseline Profiles {:#creating-profile-rules}](/topic/performance/baselineprofiles/create-baselineprofile)\n- [Baseline Profiles {:#baseline-profiles}](/topic/performance/baselineprofiles/overview)\n- [Writing a Microbenchmark](/topic/performance/benchmarking/microbenchmark-write)"]]