1. Cannot fit requested classes in a single dex file (# methods: 162837 > 65536 ; # fields: 88354 > 65536)
在app的build.gradle中添加依賴,在defaultConfig中添加以下代碼【注意:必須是app這個module,不能是其他的module】
apply plugin: 'com.android.application'
android {
defaultConfig {
//
multiDexEnabled true
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
果你自定義了Application子類,需要在這個子類中重寫一個方法
@Override
public void onCreate() {
super.onCreate();
// 主要是添加下面這句代碼
MultiDex.install(this);
}
問題描述如下
Duplicate class org.intellij.lang.annotations.Identifier found in modules jetified-annotations-12.0.jar (com.intellij:annotations:12.0) and jetified-annotations-13.0.jar (org.jetbrains:annotations:13.0) Duplicate class org.intellij.lang.annotations.JdkCon
解決辦法
在 應用 build.gradle 里添加 如下代碼
configurations {
cleanedAnnotations
compile.exclude group: 'org.jetbrains' , module:'annotations'
}