为了解决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);
}
网友评论