引用第三方库的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. 创建线程的一般方式和匿名内部类方式对比——继承thread类,重写run()方法

    第一种:继承thread类,重写run()方法 一般方式:Demo01.java /** * 创建线程的第一种方式:继承thread类,重写run()方法 * * @author :liuqi * @ ...

  2. 关机,重启BAT命令

    关机命令shutdown -s -t 重启命令 shutdown -r -t

  3. [CF1093E]Intersection of Permutations

    [CF1093E]Intersection of Permutations 题目大意: 给定两个长度为\(n(n\le2\times10^5)\)的排列\(A,B\).\(m(m\le2\times1 ...

  4. python_非阻塞套接字及I/O流

    http://www.cnblogs.com/lixy-88428977/p/9638949.html 首先,我们要明确2个问题: 普通套接字实现的服务端有什么缺陷吗? 有,一次只能服务一个客户端! ...

  5. [BZOJ1047][HAOI2007]理想的正方形(RMQ+DP)

    题意 有一个a*b的整数组成的矩阵,现请你从中找出一个n*n的正方形区域,使得该区域所有数中的最大值和最小值的差最小. 思路 RMQ求 再DP 代码 #include<cstdio> #i ...

  6. SQLServer表、列备注管理

    在开发时,为了方便,在SQL SERVER库内对表名.列名进行备注,但在DB部署客户时,想一次清理上述备注值. 特编写如下 SQL,一次清除上述备注内容: declare @table nvarcha ...

  7. ajaj简介

    1. 什么是ajax? ajax的全称 Asynchronous(异步) JavaScript and XML. ajax是一种用于创建快速动态网页的技术. 主要用于前后台的交互,在前后台的交互中还有 ...

  8. 你不知道的JS之 this 和对象原型(一)this 是什么

     原文:你不知道的js系列 JavaScript 的 this 机制并没有那么复杂 为什么会有 this? 在如何使用 this 之前,我们要搞清楚一个问题,为什么要使用 this. 下面的代码尝试去 ...

  9. 判断js中的数据类型的几种方法

    判断js中的数据类型有一下几种方法:typeof.instanceof. constructor. prototype. $.type()/jquery.type(),接下来主要比较一下这几种方法的异 ...

  10. CIKM 2012 papers to be downloaded

    http://dl.acm.org/citation.cfm?id=2398426   http://dl.acm.org/citation.cfm?id=2396825   http://dl.ac ...