Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException with DexPathList

Tags:

android

dex

I have this exception sometimes on my Samsung S3 (4.4 SDK version):

Caused by java.lang.ClassNotFoundException: Didn't find class "android.graphics.drawable.Icon" on path: DexPathList[[zip file "/data/app/com.xxxx-1.apk", zip file "/data/data/com.xxxx/code_cache/secondary-dexes/com.xxxx-1.apk.classes2.zip"],nativeLibraryDirectories=[/data/app-lib/com.xxxx-1, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

I followed exactly these elements: https://developer.android.com/studio/build/multidex.html

On my Samsung S5 (6 SDK), there is no problem.

like image 434
anthony Avatar asked Aug 29 '17 15:08

anthony


1 Answers

See the documentation; android.graphics.drawable.Icon was added in API level 23 (Android 6.0 Marshmallow). It does not exist on older devices.

Depending on your needs, android.support.v4.graphics.drawable.IconCompat could be used instead. It was added in support library 26.0.0, so you need to include com.android.support:support-compat:26.0.0 or newer (currently the latest is 26.0.1) as a dependency, as well as targetSdkVersion matching the support library. Support library 26 allows for a minimum SDK level 14.

like image 189
ephemient Avatar answered Nov 17 '22 15:11

ephemient