欢迎来到破竹的博客

人生三从境界:昨夜西风凋碧树,独上高楼,望尽天涯路。 衣带渐宽终不悔,为伊消得人憔悴。 众里寻他千百度,蓦然回首,那人却在灯火阑珊处。

Android Studio开发中的构建异常和解决办法

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'
}

posted @ 2020-05-10 10:50  破竹  阅读(2739)  评论(0编辑  收藏  举报