androidandroid-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. For that reason, in my app/build.gradle I changed minSdkVersion 16 to 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:

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? This is considering that my app will not support Android 5.x and lower anymore. Thank you.


Solution

  • The solution to this problem is to add the following in Dependencies in build.gradle (:app):

    dependencies {
      implementation 'com.android.support:multidex:1.0.3'
    }