ML Kit Android 앱의 APK 크기 줄이기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
ML Kit 기기 내 모델을 사용하는 앱을 프로덕션에 배포하기 전에 이 페이지의 권장 사항을 참고하여 앱 다운로드 크기를 줄이는 것이 좋습니다.
Android App Bundle로 앱 빌드
Android App Bundle로 앱을 빌드 및 배포하여 Google Play가 특정 화면 밀도, CPU 아키텍처, 언어를 위한 APK를 자동으로 생성할 수 있도록 합니다. 사용자는 자신의 기기 설정과 일치하는 APK를 다운로드하기만 하면 됩니다. 가장 중요한 점은 사용자는 기기 아키텍처와 일치하는 네이티브 코드 라이브러리만 다운로드한다는 것입니다.
고급: 선택사항 ML 기능을 동적 기능 모듈로 이동
주 용도가 아닌 앱 기능에 ML Kit를 사용하는 경우 앱을 리팩터링하여 기능과 ML Kit 종속 항목을 동적 기능 모듈로 옮기는 방법을 고려하세요.
ML Kit 기능이 주문형 기능 모듈에서 작동하려면 기본 APK의 build.gradle
파일에 ML Kit Play 스토어 동적 기능 지원 라이브러리 종속 항목을 포함합니다.
dependencies {
// ...
implementation 'com.google.mlkit:playstore-dynamic-feature-support:16.0.0-beta2'
}
이렇게 하면 용량이 클 수 있는 앱의 ML 모델을 사용자가 불필요하게 다운로드하지 않도록 할 수 있습니다.
고급: 사용되지 않는 ML Kit 바이너리 제외
ML Kit는 32비트 및 64비트 아키텍처를 모두 지원하도록 빌드됩니다. 앱이 32비트 모드만 지원하는 경우(예를 들어 32비트 바이너리만 제공하는 라이브러리를 사용하는 경우) 사용되지 않는 ML Kit 라이브러리를 빌드에서 제외할 수 있습니다.
android {
defaultConfig {
ndk {
// Don't package arm64-v8a or x86_64
abiFilters 'armeabi-v7a', 'x86'
}
}
}
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-29(UTC)
[null,null,["최종 업데이트: 2025-08-29(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```"]]