Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error get Font Landroid/content/Context;ILandroid/util/TypedValue [duplicate]

Tags:

java

android

I have problem with my project. I don't know how to fix it. This is first time I meet it.

/UncaughtException: java.lang.NoSuchMethodError: No static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)Landroid/graphics/Typeface; in class Landroid/support/v4/content/res/ResourcesCompat; or its super classes (declaration of 'android.support.v4.content.res.ResourcesCompat' appears in /data/app/codes.trongtin.h.besttrip-2/split_lib_dependencies_apk.apk:classes2.dex)

like image 404
Huỳnh Trọng Tín Avatar asked Oct 26 '17 03:10

Huỳnh Trọng Tín


3 Answers

It seems you are using support dependencies. Just check in your app gradle that your build tools version is the same as support versions.

For example:

android {
...
    buildToolsVersion "26.0.2"
...
}

and

dependencies {
...
    compile 'com.android.support:support-v4:26.0.2'
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.android.support:recyclerview-v7:26.0.2'
    compile 'com.android.support:support-v13:26.0.2'
...
}

must have the same version.

It worked for me!

like image 88
Agustín Ruiz Linares Avatar answered Oct 19 '22 15:10

Agustín Ruiz Linares


Just Change complieSdkVersion, buildToolsVersion and appCompat dependency.

      compileSdkVersion 27
      buildToolsVersion '27.0.0'

      implementation 'com.android.support:appcompat-v7:27.0.2'
like image 25
Dheeraj Rijhwani Avatar answered Oct 19 '22 17:10

Dheeraj Rijhwani


Thanks @agustin-ruiz-linares for the correct answer.

I'll add my setup here along with the Firebase and Glide libraries that I'm using in case its helpful for someone. I was seeing the error until I reconciled the library versions along with the buildToolsVersion and targetSdkVersions, too.

android {
    compileSdkVersion 27
    defaultConfig {
        minSdkVersion 20
        targetSdkVersion 27
        buildToolsVersion "27.0.2"
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:design:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.firebaseui:firebase-ui-database:3.2.1'
    implementation 'com.github.bumptech.glide:glide:4.5.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
    implementation 'com.android.support:support-v4:27.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
like image 33
Lucy Avatar answered Oct 19 '22 15:10

Lucy