NoClassDefFoundError on Calligraphy library

后端 未结 6 607
南笙
南笙 2021-01-01 19:49

After adding compile \'com.android.support:support-v13:21.0.+\' to build.gradle, I had some conflicts on building my app, so I had to add m

相关标签:
6条回答
  • 2021-01-01 19:55

    What i did was too update the compiling library in app level gradle file.

    compile 'com.android.support:multidex:1.0.0'
    

    I updated it too

    compile 'com.android.support:multidex:1.0.1'
    

    and it worked fine for me. Maybe this helps someone.

    0 讨论(0)
  • 2021-01-01 20:03

    If your application extends from Application then override attachBaseContext inside Application i.e

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
    

    Also need to add dependency

    compile 'com.android.support:multidex:1.0.1'
    
    0 讨论(0)
  • 2021-01-01 20:07

    MultiDex.install(this);

    This can fix the problem.

    0 讨论(0)
  • 2021-01-01 20:14

    If you support API levels under 21, your Application class should extend MultiDexApplication from the support library.

    class MyApplication extends MultiDexApplication
    

    If you do not have a custom Application class, than you should add the MultiDexApplication class to your manifest directly

    <application
        android:name="android.support.multidex.MultiDexApplication">
    </application>
    

    See https://developer.android.com/tools/building/multidex.html

    0 讨论(0)
  • 2021-01-01 20:15

    Goodlife is here again to the rescue . Add this line to ur java file that extends application.

     public void onCreate() {
        super.onCreate();
    
        mInstance = this;
    
        //ADD MULTIDEX.INSTALL(THIS) SOLVED MY SIMILAR PROBLEM
        MultiDex.install(this);
        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                        .setDefaultFontPath("fonts/Roboto-Regular.ttf")
                        .setFontAttrId(R.attr.fontPath)
                        .build()
        );
    }
    
    0 讨论(0)
  • 2021-01-01 20:19

    Yes,update to multidex 1.0.2 and add Mulitidex.install(this) to the class extending application

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