引用第三方库的jar文件,都有可能会触发这个错误。解决方案如下:

参考《[Android]Cannot fit requested classes in a single dex file. Try supplying a main-dex list.

一、在app的build.gradle中添加依赖,在defaultConfig中添加以下代码【注意:必须是app这个module,不能是其他的module】

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
applicationId "com.why.project.poidemo"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" //
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
} //poi
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
} dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.android.support:multidex:1.0.3'
}

二、如果你自定义了Application子类,需要在这个子类中重写一个方法

@Override
public void onCreate() {
super.onCreate();
// 主要是添加下面这句代码
MultiDex.install(this);
}

Error: Cannot fit requested classes in a single dex file (# methods: 149346 > 65536)的更多相关文章

  1. Android开发 Error:The number of method references in a .dex file cannot exceed 64K.

    在Android系统中,一个App的所有代码都在一个Dex文件里面.Dex是一个类似Jar的存储了多有Java编译字节码的归档文件.因为Android系统使用Dalvik虚拟机,所以需要把使用Java ...

  2. CentOS编译安装Apache 2.4.x时报错:configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

    先前按照这篇文章“CentOS6.x编译安装LAMP(2):编译安装 Apache2.2.22”去编译安装Apache2.2.x版本时,安装得挺顺利,今天换成Apache2.4.x版本,安装方法一样, ...

  3. PYCURL ERROR 22 - "The requested URL returned error: 403 Forbidden"

    RHEL6.5创建本地Yum源后,发现不可用,报错如下: [root@namenode1 html]# yum install gcc Loaded plugins: product-id, refr ...

  4. configure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.

    Apache在2.4版本以后,编译时: # ./configure \ --prefix=/usr/local/apache2 \ --with-included-apr \ --enable-so ...

  5. Error: MDM failed command. Status: Only a single SDC may be mapped to this volume at a time

    映射一个volume到多个SDC的时候报错如下: Error: MDM failed command.  Status: Only a single SDC may be mapped to this ...

  6. 002——keil-Error: L6915E: Library reports error: __use_no_semihosting was requested解决

    ..\OBJ\KEY.axf: Error: L6915E: Library reports error: __use_no_semihosting was requested, but _ttywr ...

  7. 安装docker报错:https://download.docker.com/linux/centos/7/i386/stable/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

    如题,执行docker安装命令报错: [root@centos ~]# yum install docker-ce Loaded plugins: fastestmirror, security Se ...

  8. yum异常: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

    http://people.centos.org/hughesjr/chromium/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 ...

  9. Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.

    启动tomcat, 出现, ( 之前都是好好的... ) [lk ] ERROR [08-12 15:10:02] [main] org.springframework.web.context.Con ...

随机推荐

  1. docker-compose.yml 配置文件详解及项目发布

    摘自:https://blog.csdn.net/qq_36148847/article/details/79427878 docker部署tomcat项目 1.上传war包2.制作镜像 Docker ...

  2. 学习随笔:Vue.js与Django交互以及Ajax和axios

    1. Vue.js地址 Staticfile CDN(国内): https://cdn.staticfile.org/vue/2.2.2/vue.min.js unpkg:会保持和npm发布的最新的版 ...

  3. centos7基于samba服务配置实例

    需求: 账号建立:产研部门所有人员,产品.开发.测试.运维: 目录建立:各二级部门分别建立以部门名称为文件夹的目录: 初步权限管理:各部门成员对本部门目录有读写权限,对其他部门目录有读权限: 建立共享 ...

  4. Vue.set() this.$set()引发的视图更新思考

    引文 vue文档列表渲染中有条注意事项: 这里提到的两种情况实际改变了数据但是没有触发视图更新. 由此引出Vue.set(),先上文档API: this.$set()和Vue.set()本质方法一样, ...

  5. 201771010126 王燕《面向对象程序设计(java)》第十一周学习总结

    实验十一   集合 实验时间 2018-11-8 1.实验目的与要求 (1) 掌握Vetor.Stack.Hashtable三个类的用途及常用API: Vector类实现了长度可变的数组. Vecto ...

  6. Vue 项目: npm run dev 报错 webpack-dev-server

    从码云上下载vue项目,运行npm run dev 时报错: > webpack-dev-server --inline --progress --config build/webpack.de ...

  7. c#使用 Newtonsoft.Json 将entity转json时,忽略为null的属性

    c#使用 Newtonsoft.Json 将entity转json时,忽略为null的属性,直接在属性上加下面的特性 [JsonProperty(NullValueHandling=NullValue ...

  8. sublime text3 在 14.04.1-Ubuntu 下的中文输入

    1.安装 fcitx sudo add-apt-repository ppa:fcitx-team/nightly // 添加FCITX仓库. sudo apt-get update // 更新仓库. ...

  9. Ooui.Wasm:浏览器中的.NET

    小型.NET Web框架Ooui作为Web程序集(WASM)在浏览器中完全运行 – 不需要服务器端的交互,涉及的所有文件都直接从浏览器执行,.NET Web框架Ooui可以作为其开发人员Frank A ...

  10. eclipse集成lombok

    第一部下载 lombok jar包 https://projectlombok.org/download.html lombok下载地址,进入该网址后可以看到如下界面,点击下载就行了.   下载 ja ...