引用第三方库的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. redis与memacache的区别(转)

    redis和memecache的不同在于:1.存储方式:memecache 把数据全部存在内存之中,断电后会挂掉,数据不能超过内存大小redis有部份存在硬盘上,这样能保证数据的持久性.2.数据支持类 ...

  2. 首次安装Ubuntu

    初试Ubuntu 双系统的安装 situation: dell(2017购) 固态250G+机械硬盘500G 已经安装windows 10 BIOS 为 UEFI rufus(向U盘写入镜像) Ubu ...

  3. Linux-软中断通信

    进程间通信-软中断 内容 使用软中段机制实现Linux进程间通信 机理说明 ​ 软中断信号(signal)是一种简单且最基本的进程通信机制,它最大的特点是提供了一种简单的处理异步事件的方法.例如,常见 ...

  4. block学习二:使用Block替代回调

    使用Block替代回调,分为三步进行:

  5. powershell_基础篇

    powershell 想必大家对windows操作系统下的cmd命令提示符可能并不陌生,大多数人都应该使用过它.而对于今天我们要学习的PowerShell跟cmd有什么关系呢?可以简单地说,Power ...

  6. C++第四课:类的使用(二)[个人见解]

    前面说到C++类的名字自定义要有含义,成员函数名也同样如此. 一个好的程序员除了让自己能看懂代码外,那是能力,也能让别人看懂,那是本事. 我们来看第一个特性:继承! 什么是继承? 小编不说概念性的定义 ...

  7. 1、初识Java

    1.计算机发展过程 2.Java简史 lSUN公司是一家什么样的公司? 美国SUN(Stanford University Network)公司 在中国大陆的正式中文名为“太阳计算机系统(中国)有限公 ...

  8. [zt]C++二维数组讲解、二维数组的声明和初始化

    定义: int *pia = new int[10]; // array of 10 uninitialized ints 此 new 表达式分配了一个含有 10 个 int 型元素的数组,并返回指向 ...

  9. 继承ipkPlayer中出现的一些错误汇总

    1.下载完ffmpeg后,我们再在终端执行下面两个命令: cd ios./compile-ffmpeg.sh clean./compile-ffmpeg.sh all 大体流程如下  这里如果出现 x ...

  10. DHCP工作原理简析

    引言 DHCP是网络体系结构中应用层的一个重要协议,它可以帮助我们对要连接到互联网的计算机进行IP地址等信息的配置.本文从DHCP的原理出发,就DHCP的工作过程 进行详细的探讨. 主要报文 发现报文 ...