[英]error: package android.support.multidex does not exist whem upgrading from minSdkVersion 16 to minSdkVersion 23
My app is not supporting Android 4.x and 5.x anymore, only Android 6.0 and higher. 我的应用不再支持Android 4.x和5.x,仅支持Android 6.0及更高版本。 For that reason, in my app/build.gradle
I changed minSdkVersion 16
to minSdkVersion 23
. 因此,在我的app/build.gradle
我将minSdkVersion 16
更改为minSdkVersion 23
。 After doing that, I have started to get this error when I try to run the app: 之后,当我尝试运行该应用程序时,我开始出现此错误:
error: package android.support.multidex does not exist
error: cannot find symbol variable MultiDex
In one of my .java
files, I see the errors in the following lines: 在我的一个.java
文件中,我在以下几行中看到错误:
import android.support.multidex.MultiDex;
MultiDex.install(this);
Should I simply not use MultiDex
because Android 6.0 and higher do not need that anymore? 我是否应该因为Android 6.0及更高版本不再使用MultiDex
而不再使用它? This is considering that my app will not support Android 5.x and lower anymore. 考虑到我的应用不再支持Android 5.x及更低版本。 Thank you. 谢谢。
The solution to this problem is to add the following in Dependencies in build.gradle : 解决此问题的方法是在build.gradle的Dependencies中添加以下内容:
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
尝试在build.gradle(app)中将multiDexEnabled设置为true
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here: 如果将minSdkVersion设置为21或更高,则只需在模块级build.gradle文件中将multiDexEnabled设置为true,如下所示:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
...
}
https://developer.android.com/studio/build/multidex https://developer.android.com/studio/build/multidex
I needed to change 我需要改变
import android.support.multidex.MultiDex
to 至
import androidx.multidex.MultiDex
to reference the "newer" MultiDex
's location (version 1.0.3 in my case). 引用“较新的” MultiDex
的位置(在我的情况下为1.0.3版)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.