Calligraphy icon indicating copy to clipboard operation
Calligraphy copied to clipboard

NoClassDefFoundError: uk.co.chrisjenx.calligraphy.CalligraphyConfig$Builder

Open nishantpardamwar opened this issue 8 years ago • 4 comments

Getting java.lang.NoClassDefFoundError: uk.co.chrisjenx.calligraphy.CalligraphyConfig$Builder when running my app on android 4.4.4, on above android 5.0 its running fine.

tried all the solution i found.

app build.gradle


android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        .
        .
        minSdkVersion 16
        targetSdkVersion 22
        jackOptions {
            enabled true
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        multiDexEnabled true
    }
}

dependencies {
        .
        .
        compile 'com.android.support:multidex:1.0.1'
        .
        .
}

my custom application class extending MultiDexApplication


public class App extends MultiDexApplication {
    @Override
        public void onCreate() {
            super.onCreate();
            .
            .
            CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                .setDefaultFontPath(Constants.FONT_REGULAR)
                .setFontAttrId(R.attr.fontPath)
                .build());
             .
             .
        }
}

project build.gradle


buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

nishantpardamwar avatar Feb 28 '17 12:02 nishantpardamwar

found the solution, the error was due to jack compiler adding these lines fixed it.

 defaultConfig {
    .
    .
    jackOptions {
                enabled true
                jackInProcess true
                additionalParameters("jack.dex.output.policy" : "multidex")
                additionalParameters("jack.preprocessor.file" : "legacyMultidexInstallation.jpp")
                additionalParameters("jack.preprocessor" : "true")
                additionalParameters("jack.dex.output.multidex.legacy": "true")
    }
    .
    .
}

download legacyMultidexInstallation.jpp from here and put it into your project root folder(not in app folder).

nishantpardamwar avatar Mar 01 '17 05:03 nishantpardamwar

Having the same problem, the solution proposed by nishantpardamwar is incompatible with data binding library.

Finally solved the problem extending application class from MultiDexApplication

miibpa avatar Mar 02 '17 09:03 miibpa

Also - don't use Jack - he's dead.

chrisjenx avatar Apr 04 '17 17:04 chrisjenx

Solved the problem extending application class from MultiDexApplication

If you're using for more than Lolipop versions as well then you have to include the library compile 'com.android.support:multidex:1.0.1'

kalkotekedar avatar Sep 18 '17 04:09 kalkotekedar