简体   繁体   English

错误:从minSdkVersion 16升级到minSdkVersion 23的软件包android.support.multidex不存在

[英]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.

相关问题 升级到 Android Studio 2.3 后出现“包 android.support.multidex 不存在” - Getting "package android.support.multidex does not exist" after upgrading to Android Studio 2.3 android.support.multidex在Xamarin中的位置 - Where does android.support.multidex reside in Xamarin Android compileSdkVersion 23, minSdkVersion 15, targetSdkVersion 23 - Android compileSdkVersion 23, minSdkVersion 15, targetSdkVersion 23 MultiDexTestRunner的哪个包? android.support.multidex或com.android.test.runner - Which package for MultiDexTestRunner? android.support.multidex or com.android.test.runner 将minSdkVersion从15更改为16 - Changing minSdkVersion from 15 to 16 firebase 消息来自 android 上的 minSdkVersion 错误与 flutter - firebase messaging from minSdkVersion error on android with flutter Android minSdkVersion - Android minSdkVersion 我的config.xml的minSdkVersion为16,但cordova构建目标为android-23。 它仍然可以在较低的SDK android上运行吗? - My config.xml has minSdkVersion as 16 but cordova build targets targetting android-23. Will it still work on a lower SDK android? InstantApp支持使用“ minSdkVersion”吗? - “minSdkVersion” for InstantApp support? 如果targetSdkVersion = 23(棉花糖),当minSdkVersion &lt;targetSdkVersion时,Android皮棉不会显示错误 - Android lint not showing errors when minSdkVersion < targetSdkVersion, if targetSdkVersion=23 (Marshmallow)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM