MultiDex NoClassDefFound error

后端 未结 8 631
醉梦人生
醉梦人生 2020-11-29 05:52

I have converted my application into MultiDex to bear with 64k dex limit. Now it looks like this:

public class App extends MultiDexApplication {

private App         


        
相关标签:
8条回答
  • 2020-11-29 06:40

    If anyone gets here because their Application class is not being found on pre-Lollipop devices, but the app runs fine on Lollipop and above then this appears to be a known issue with Jack and Multidex.

    Ref: Jack Issue 213484

    Ref: Jack Issue 224026

    0 讨论(0)
  • 2020-11-29 06:44

    I've finally solved it! Cause was not in the onCreate() method. There was this line from logcat that gained my attention:

    I/dalvikvm﹕ Failed resolving     Lcom/playday/app/core/AppWrapper; interface 8940 'Lretrofit/ErrorHandler;'
    W/dalvikvm﹕ Link of class     'Lcom/playday/app/core/AppWrapper;' failed
    

    This line fired before all the MultiDex log. Source of the problem was Retrofit ErrorHandler interface, which AppWrapper implements.

    As @AlexLipov said in his answer, Dalvik just couldn't find ErrorHandler class and failed to load AppWrapper.

    Anyway, solution is not to implement ErrorHandler directly by AppWrapper and pull it into private variable instead.

    0 讨论(0)
提交回复
热议问题