java.lang.NoClassDefFoundError on Android version lower than Lollipop

岁酱吖の 提交于 2019-12-05 06:03:39

Your class (the first anonymous class in GetProjectTask) extends a class that is not available on that platform.

If you look carefully at the API documentation you will notice "added in API x" at the top right corner of class documentation, and similar text in each and every API method.

For example see AnimatedVectorDrawable - it was added at API level 21 (Lollipop).

Attempting to use a class that was added at API 21 on older devices will fail with the exception that you hit. That is not surprising since unfortunately the newer features are not available in older OS versions.

You can overcome this exception in several ways: using compatibility libraries, enabling new features only if the phone supports it (by checking Build.Version.SDK_INT or using api level specific res folder eg. layout-v21.

Another alternative is to set the minSdkVersion to 21, then your app will refuse to install on older devices (and will not be available in their Google Play stores).

See Android docs on compatibility for more details on this subject.

Libin Thomas

This fixed it for me, add on build.gradle:

 dexOptions {
        preDexLibraries = false
        javaMaxHeapSize = "4g"
    }

Compile 'javax.inject:javax.inject:1'

Extends MultiDexApplication in application class

Don't @Override the attachBaseContext method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!