為了解決65535問題,需要在項目中添加Multidex的配置。按照下面的步驟在項目中進行配置即可:
app中的build.gradle的配置
apply plugin: 'com.android.application'
...
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
configurations {
}
signingConfigs {
config {
...
}
}
defaultConfig {
...
multiDexEnabled true
...
}
buildTypes {
release {
...
}
}
//忽略lint錯誤
lintOptions {
abortOnError false
}
kotlin {
experimental {
coroutines 'enable'
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
packagingOptions {
...
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
...
/** 支持庫 */
compile rootProject.ext.dependencies["multidex"]
...
}
在Applicition實現類中添加下面的代碼
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
//將Multidex注入到項目中
MultiDex.install(base);
}