한마디로 여러 개의 덱스 파일을 사용할 수 있다는 것입니다. 아래의 설명에서 보듯이, 안드로이드 파일은 파일 한 개당 65,536 메소드/프레임워크/라이브러리 등을 가질 수 있습니다. API 21 미만에서는 65,536이 넘어가게 되면 멀티덱스 지원라이브러를 사용해야 하고, API 21 이상에서는 설정만 가볍게 바꾸면 됩니다. 물론 API 21 이하에서도 쉽습니다만 지원라이브러를 꼭 추가해줘야 합니다.
# stackoverflow
It's as simple as this
A single .dex file can have 65,536 methods(references) so if the number of references exceed 65,536, you go with multidex.
More Explanation !
An android application program is compiled into a .dex file which in turn zipped to a single .apk file.
DVM (Dalvik Virtual Machine) uses .dex file/files to execute bytecodes.
DVM (Dalvik Virtual Machine) uses .dex file/files to execute bytecodes.
What causes number of references to exceed 65,536 limit ?
Methods written by you + Android Framework methods + Third party library(eg Volley,Retrofit,Facebook SDK etc) methods.
I have read "somewhere"
App Compat 24.2.1 contains 16.5k methods
Google Play Services GCM 9.6.1 contains 16.7k methods
So if you have created a simple Hello world application which has App Compat 24.2.1, you are already 1/4 way to cross the single dex methods limit
#AndroidDeveloperMethods written by you + Android Framework methods + Third party library(eg Volley,Retrofit,Facebook SDK etc) methods.
I have read "somewhere"
App Compat 24.2.1 contains 16.5k methods
Google Play Services GCM 9.6.1 contains 16.7k methods
So if you have created a simple Hello world application which has App Compat 24.2.1, you are already 1/4 way to cross the single dex methods limit
Android 플랫폼이 계속 성장함에 따라 Android 앱의 크기도 따라서 증가합니다. 앱과 이 애플리케이션이 참조하는 라이브러리의 크기가 일정 크기에 도달하면, 앱이 Android 앱 빌드 아키텍처의 제한에 도달했음을 나타내는 빌드 오류가 발생합니다. 이전 버전의 빌드 시스템에서는 이 오류를 다음과 같이 보고합니다.
Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
그보다 최근의 Android 빌드 시스템 버전에서는 다른 오류를 표시하지만 이 오류는 동일한 문제를 나타내는 것입니다.
trouble writing output: Too many field references: 131000; max is 65536. You may try using --multi-dex option.
두 오류 모두 공통 숫자인 65,536을 표시합니다. 이 숫자는 단일 DEX(Dalvik Executable) 바이트코드 파일 내에서 코드가 호출할 수 있는 참조의 총 개수를 나타냅니다. 이 페이지에서는 multidex라는 앱 구성을 활성화하여 이 제한을 넘는 방법을 설명합니다. multidex는 앱이 다중 DEX 파일을 빌드하고 읽을 수 있게 해줍니다.
API 21이상이라면,
android { defaultConfig { ... minSdkVersion 21 targetSdkVersion 26 multiDexEnabled true } ... }
API21이하라면,
android { defaultConfig { ... minSdkVersion 15 targetSdkVersion 26 multiDexEnabled true } ... } dependencies { compile 'com.android.support:multidex:1.0.1' }
출처 :
https://stackoverflow.com/questions/33588459/what-is-android-multidex
https://developer.android.com/studio/build/multidex.html?hl=ko#about
https://developer.android.com/reference/android/support/multidex/MultiDex.html
https://developer.android.com/topic/libraries/support-library/features.html?hl=ko#v7
https://developer.android.com/studio/build/multidex.html?hl=ko
https://ko.wikipedia.org/wiki/%EB%8B%AC%EB%B9%85_(%EC%86%8C%ED%94%84%ED%8A%B8%EC%9B%A8%EC%96%B4)
https://source.android.com/devices/tech/dalvik/dex-format
댓글 없음:
댓글 쓰기