अपने ML Kit Android ऐप्लिकेशन के APKs का साइज़ कम करना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
अगर आपको प्रोडक्शन ट्रैक पर ऐसा ऐप्लिकेशन डिप्लॉय करना है जो ML Kit के ऑन-डिवाइस मॉडल का इस्तेमाल करता है, तो हमारा सुझाव है कि आप इस पेज पर दी गई सलाह को अपनाएं. इससे आपके ऐप्लिकेशन का डाउनलोड साइज़ कम हो जाएगा.
अपने ऐप्लिकेशन को Android ऐप्लिकेशन बंडल के तौर पर बनाना
अपने ऐप्लिकेशन को Android ऐप्लिकेशन बंडल के तौर पर बनाएं और डिप्लॉय करें, ताकि Google Play खास स्क्रीन डेंसिटी, सीपीयू आर्किटेक्चर, और भाषाओं के लिए APK अपने-आप जनरेट कर सके. लोगों को सिर्फ़ वे APK डाउनलोड करने होंगे जो उनके डिवाइस के कॉन्फ़िगरेशन से मेल खाते हैं. साथ ही, लोगों को सिर्फ़ वे नेटिव कोड लाइब्रेरी डाउनलोड करनी होंगी जो उनके डिवाइस के आर्किटेक्चर से मेल खाती हैं.
ऐडवांस: एमएल की वैकल्पिक सुविधाओं को डाइनैमिक फ़ीचर मॉड्यूल में ले जाना
अगर आपने अपने ऐप्लिकेशन की किसी ऐसी सुविधा में ML Kit का इस्तेमाल किया है जो उसका मुख्य मकसद नहीं है, तो अपने ऐप्लिकेशन को फिर से फ़ैक्टर करने पर विचार करें. इससे उस सुविधा और उसकी ML Kit डिपेंडेंसी को डाइनैमिक फ़ीचर मॉड्यूल में ले जाया जा सकता है.
मांग पर उपलब्ध सुविधा वाले मॉड्यूल में ML Kit की सुविधाओं का इस्तेमाल करने के लिए, अपने बेस APK की build.gradle
फ़ाइल में, ML Kit की Play Store पर डाइनैमिक सुविधा के साथ काम करने वाली लाइब्रेरी की डिपेंडेंसी शामिल करें.
dependencies {
// ...
implementation 'com.google.mlkit:playstore-dynamic-feature-support:16.0.0-beta2'
}
ऐसा करने से, उपयोगकर्ताओं को आपके ऐप्लिकेशन के एमएल मॉडल को गैर-ज़रूरी तौर पर डाउनलोड करने से रोका जा सकता है. ये मॉडल बड़े हो सकते हैं.
ऐडवांस: इस्तेमाल नहीं की गई ML Kit बाइनरी को बाहर रखें
ML Kit को 32-बिट और 64-बिट, दोनों आर्किटेक्चर के साथ काम करने के लिए बनाया गया है. अगर आपका ऐप्लिकेशन सिर्फ़ 32-बिट मोड के साथ काम करता है, तो इस्तेमाल न की गई ML Kit लाइब्रेरी को अपने बिल्ड से हटाया जा सकता है. उदाहरण के लिए, अगर आपने ऐसी लाइब्रेरी का इस्तेमाल किया है जो सिर्फ़ 32-बिट बाइनरी उपलब्ध कराती है, तो यह तरीका अपनाएं:
android {
defaultConfig {
ndk {
// Don't package arm64-v8a or x86_64
abiFilters 'armeabi-v7a', 'x86'
}
}
}
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-09-10 (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-09-10 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eReduce your app's download size by building it as an Android App Bundle, enabling Google Play to deliver optimized APKs to users based on their device configurations.\u003c/p\u003e\n"],["\u003cp\u003eFor non-core ML features, leverage dynamic feature modules to deliver them on demand, minimizing the initial download size by excluding optional ML models.\u003c/p\u003e\n"],["\u003cp\u003eIf your app only supports 32-bit mode, exclude unused 64-bit ML Kit libraries to further reduce the app's size.\u003c/p\u003e\n"],["\u003cp\u003eTo enable ML Kit features in on-demand modules, include the \u003ccode\u003eplaystore-dynamic-feature-support\u003c/code\u003e library in your base APK's dependencies.\u003c/p\u003e\n"]]],[],null,["Before you deploy to production an app that uses an ML Kit on-device model,\nconsider following the advice on this page to reduce the download size of your\napp.\n\nBuild your app as an Android App Bundle\n\nBuild and deploy your app as an [Android App Bundle](//developer.android.com/guide/app-bundle/) so that Google\nPlay can automatically generate APKs for specific screen densities, CPU\narchitectures, and languages. Users will only have to download the APKs that\nmatch their device configuration, and most importantly, users only download the\nnative code libraries that match their device architecture.\n\nAdvanced: Move optional ML features to dynamic feature modules\n\nIf you use ML Kit in a feature of your app that isn't its primary purpose,\nconsider refactoring your app to move that feature and its ML Kit\ndependencies to a [dynamic feature module](//developer.android.com/studio/projects/dynamic-delivery#dynamic_feature_modules).\n\nIn order for ML Kit features to work in an on-demand feature module, in your base apk's `build.gradle` file,\ninclude the ML Kit playstore dynamic feature support library dependency. \n\n```carbon\ndependencies {\n // ...\n implementation 'com.google.mlkit:playstore-dynamic-feature-support:16.0.0-beta2'\n}\n```\n\nBy doing so, you prevent users from unnecessarily downloading your app's ML models, which can be\nlarge.\n\nAdvanced: Exclude unused ML Kit binaries\n\nML Kit is built with support for both 32-bit and 64-bit architectures. If\nyour app only supports 32-bit mode---for example, because you use a library\nthat only provides 32-bit binaries---you can exclude the unused ML Kit\nlibraries from your build: \n\n```carbon\nandroid {\n defaultConfig {\n ndk {\n // Don't package arm64-v8a or x86_64\n abiFilters 'armeabi-v7a', 'x86'\n }\n }\n}\n```"]]