๊ธฐ์กด์ ๋ฌธ์ ์์ด ์ ์ฌ์ฉํ๋ ํ๋ก์ ํธ๊ฐ ๋ช๊ฐ์ง ์์ ์ ํ๊ณ rebuild๋ฅผ ๋๋ฆฌ๋ ์๊ฐ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค. ์ด๊ฑด ๋ ๋ฌด์จ ์๋ฌ์ง? ๊ธํ๊ฒ ์คํ ์ค๋ฒํ๋ก์ฐ ๋ฐ ์๋๋ก์ด๋ Document๋ฅผ ํ์ธํ์ฌ ํด๊ฒฐ๋ฐฉ๋ฒ์ ์ฐพ์๋ณด์๋ค.
์ถ๋ ฅ๋๋ ์๋ฌ ๋ฉ์ธ์ง๋ ์๋์ ๊ฐ๋ค.
Cannot fit requested classes in a single dex file (# methods: 74581 > 65536)
์๋๋ก์ด๋ ์ค์ ์ minSdkVersion 16, AndroidX๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฏ๋ก, defaultConfig ์ค์ ๊ณผ dependencies ์ค์ ์ ์ถ๊ฐํ๋ค. ์๋๋ก์ด๋๋ ๋ฒ์ ์ ๋ฐ๋ฅธ ์ค์ ํธํ์ด ์ฐธ ๊น๋ค๋ก์ด๊ฒ ๊ฐ๋ค. (๋ญ๊ฐ ์ฝ๊ฒ ๊นจ์ง๋ ๊ณ๋๊ฐ์ ๋๋์ด ๋ค์ด์ ์์ ํ๋ฉด์ ๊ด์๋ฆฌ ๊ฑฑ์ ์ด ๋๋ ๋ถ๋ถ๋ค์ด ์์๋ค.)
์์ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ๋ ์์ธ์, ์๋๋ก์ด๋ apkํ์ผ์ dexํ์ผ ํ์์ ์คํ ๊ฐ๋ฅํ ๋ฐ์ดํธ ์ฝ๋ ํ์ผ์ด ์๊ณ ํ์ผ ๋ด ์ฐธ์กฐ ๊ฐ๋ฅํ ๋ฉ์๋ ๊ฐฏ์๊ฐ 65,536์ผ๋ก ์ ํ๋๋ค. ๊ทธ๋ฐ๋ฐ ์งํ์ค์ธ ํ๋ก์ ํธ ๋ด ์ถ๊ฐํ๋ ค๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํฌํจ๋๋ฉด์ dexํ์ผ ๋ด ๋ฉ์๋ ๊ฐฏ์๊ฐ ์ด๊ณผ๋์ด ์๋ฌ๊ฐ ๋ฐ์ํ๋ค. ๊ทธ๋์ multiDexEnabled true์ dependencies์์ dex ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ถ๊ฐํด์ฃผ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค.
build.gradle ํ์ผ
android {
compileSdkVersion 30
buildToolVersion "30.0.3"
defaultConfig {
applicationId "com.example.project"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}
์ด๋ ๊ฒ ์ค์ ํ๋ฉด ๋ฆฌ๋น๋์ ๋ฐ์ํ๋ ์๋ฌ๊ฐ ํด๊ฒฐ๋๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค.
์ฐธ๊ณ
https://developer.android.com/studio/build/multidex#groovy
๋๊ธ