लाइब्रेरी के लिए बेसलाइन प्रोफ़ाइल बनाएं
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
किसी लाइब्रेरी के लिए बेसलाइन प्रोफ़ाइल बनाने के लिए,
बेसलाइन प्रोफ़ाइल Gradle प्लग इन.
किसी लाइब्रेरी के लिए बेसलाइन प्रोफ़ाइल बनाने में तीन मॉड्यूल शामिल हैं:
- ऐप्लिकेशन के लिए सैंपल मॉड्यूल: इसमें उस ऐप्लिकेशन का सैंपल होता है जो आपकी लाइब्रेरी का इस्तेमाल करता है.
- लाइब्रेरी मॉड्यूल: वह मॉड्यूल जिसके लिए आपको प्रोफ़ाइल जनरेट करनी है.
- बेसलाइन प्रोफ़ाइल मॉड्यूल: ऐसा जांच मॉड्यूल जो बेसलाइन प्रोफ़ाइल जनरेट करता है.
किसी लाइब्रेरी के लिए बेसलाइन प्रोफ़ाइल जनरेट करने के लिए, यह तरीका अपनाएं:
- एक नया
com.android.test
मॉड्यूल बनाएं—उदाहरण के लिए,
:baseline-profile
.
- इसके लिए
build.gradle.kts
फ़ाइल को कॉन्फ़िगर करें:
:baseline-profile
मॉड्यूल. कॉन्फ़िगरेशन है
ऐप्लिकेशन के लिए ज़रूरी है, लेकिन पक्का करें कि आपने
targetProjectPath
को सैंपल ऐप्लिकेशन मॉड्यूल में भेजा गया है.
:baseline-profile
में बेसलाइन प्रोफ़ाइल टेस्ट बनाएं
टेस्ट मॉड्यूल. यह जानकारी, सैंपल ऐप्लिकेशन के हिसाब से होनी चाहिए. साथ ही, इसमें सभी ऐप्लिकेशन का इस्तेमाल होना चाहिए
लाइब्रेरी की सुविधाओं के बारे में जानकारी.
- इसमें
build.gradle.ktss
फ़ाइल का कॉन्फ़िगरेशन अपडेट करें:
लाइब्रेरी मॉड्यूल के लिए, :library
कहें.
androidx.baselineprofile
प्लग इन लागू करें.
- एक
baselineProfile
डिपेंडेंसी जोड़ें
:baseline-profile
मॉड्यूल.
- अपने हिसाब से उपभोक्ता प्लगिन कॉन्फ़िगरेशन लागू करें, जैसा कि
नीचे दिया गया उदाहरण देखें.
Kotlin
plugins {
id("com.android.library")
id("androidx.baselineprofile")
}
android { ... }
dependencies {
...
// Add a baselineProfile dependency to the `:baseline-profile` module.
baselineProfile(project(":baseline-profile"))
}
// Baseline Profile Gradle plugin configuration.
baselineProfile {
// Filters the generated profile rules.
// This example keeps the classes in the `com.library` package all its subpackages.
filter {
include "com.mylibrary.**"
}
}
ग्रूवी
plugins {
id 'com.android.library'
id 'androidx.baselineprofile'
}
android { ... }
dependencies {
...
// Add a baselineProfile dependency to the `:baseline-profile` module.
baselineProfile ':baseline-profile'
}
// Baseline Profile Gradle plugin configuration.
baselineProfile {
// Filters the generated profile rules.
// This example keeps the classes in the `com.library` package all its subpackages.
filter {
include 'com.mylibrary.**'
}
}
androidx.baselineprofile
प्लगिन को इसमें जोड़ें
ऐप्लिकेशन मॉड्यूल में build.gradle.kts
फ़ाइल
:sample-app
.
Kotlin
plugins {
...
id("androidx.baselineprofile")
}
ग्रूवी
plugins {
...
id 'androidx.baselineprofile'
}
- नीचे दिए गए कोड की मदद से प्रोफ़ाइल जनरेट करें:
./gradlew :library:generateBaselineProfile
.
जनरेट किए गए टास्क के खत्म होने पर, बेसलाइन प्रोफ़ाइल
library/src/main/generated/baselineProfiles
.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, 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 Baseline Profiles for a library\n\nTo create Baseline Profiles for a library, use the\n[Baseline Profile Gradle plugin](/topic/performance/baselineprofiles/configure-baselineprofiles).\n\nThere are three modules involved in creating Baseline Profiles for a library:\n\n- Sample app module: contains the sample app that uses your library.\n- Library module: the module you want to generate the profile for.\n- Baseline Profile module: the test module that generates the Baseline Profiles.\n\nTo generate a Baseline Profile for a library, perform the following steps: \n1. Create a new `com.android.test` module---for example, `:baseline-profile`.\n2. Configure the `build.gradle.kts` file for the `:baseline-profile` module. [The configuration is\n essentially the same as for an app](/topic/performance/baselineprofiles/create-baselineprofile#create-new-profile-plugin), but make sure to set the `targetProjectPath` to the sample app module.\n3. Create a Baseline Profile test in the `:baseline-profile` test module. This needs to be specific to the sample app and must use all the functionalities of the library.\n4. Update the configuration in `build.gradle.ktss` file in the library module, say `:library`.\n 1. Apply the plugin `androidx.baselineprofile`.\n 2. Add a `baselineProfile` dependency to the `:baseline-profile` module.\n3. Apply the consumer plugin configuration you want, as shown in the following example. \n\n### Kotlin\n\n```kotlin\nplugins {\n id(\"com.android.library\")\n id(\"androidx.baselineprofile\")\n}\n\nandroid { ... }\n\ndependencies {\n ...\n // Add a baselineProfile dependency to the `:baseline-profile` module.\n baselineProfile(project(\":baseline-profile\"))\n}\n\n// Baseline Profile Gradle plugin configuration.\nbaselineProfile {\n\n // /topic/performance/baselineprofile/configure-baselineprofiles#filter-profile-rules the generated profile rules. \n // This example keeps the classes in the `com.library` package all its subpackages.\n filter {\n include \"com.mylibrary.**\"\n }\n}\n```\n\n### Groovy\n\n```groovy\nplugins {\n id 'com.android.library'\n id 'androidx.baselineprofile'\n}\n\nandroid { ... }\n\ndependencies {\n ...\n // Add a baselineProfile dependency to the `:baseline-profile` module.\n baselineProfile ':baseline-profile'\n}\n\n// Baseline Profile Gradle plugin configuration.\nbaselineProfile {\n\n // /topic/performance/baselineprofile/configure-baselineprofiles#filter-profile-rules the generated profile rules. \n // This example keeps the classes in the `com.library` package all its subpackages.\n filter {\n include 'com.mylibrary.**'\n }\n}\n```\n5. Add the `androidx.baselineprofile` plugin to the `build.gradle.kts` file in the app module `:sample-app`. \n\n ### Kotlin\n\n ```kotlin\n plugins {\n ...\n id(\"androidx.baselineprofile\")\n }\n ```\n\n ### Groovy\n\n ```groovy\n plugins {\n ...\n id 'androidx.baselineprofile'\n }\n ```\n6. Generate the profile by running the following code: `./gradlew :library:generateBaselineProfile`.\n\nAt the end of the generation task, the Baseline Profile is stored at\n`library/src/main/generated/baselineProfiles`."]]