#jhrunning



[Android] Cannot fit requested classes in a single dex file 문제 해결하기

Multidex support for Android 5.0 and higher

Android 5.0 (API level 21) and higher uses a runtime called ART which natively supports loading multiple DEX files from APK files.

 ART performs pre-compilation at app install time which scans for classesN.dex files and compiles them into a single .oat file for execution by the Android device.

Therefore, if your minSdkVersion is 21 or higher, you do not need the multidex support library.

For more information on the Android 5.0 runtime, read ART and Dalvik.

https://developer.android.com/studio/build/multidex

앱이 참조하는 메서드의 갯수가 64K를 넘어가면 발생하는 문제입니다.




build.gradle의 defaultConfig 항목에

multiDexEnabled true 속성을 추가하면문제가 해결됩니다.

minSdk가 21 미만인 경우에는

추가적으로,

2가지 작업을 해야 합니다.

1. Manifest에 아래 항목을 추가

<application

...

android:name="android.support.multidex.MultiDexApplication" >

...

</application>

2. Multidex 라이브러리 추가

dependencies {

implementation ''''androidx.multidex:multidex:2.0.1''''

}








Comments


  • {{comment.writer_name}} | {{comment.content}}



  • 작성자
  • 10 months ago
  • 조회수 62
  • 채널 jhrunning