2
votes

I am using Calligraphy Library by ChrisJenx. Suddenly today morning my project has started throwing weird error. Anyone got any idea about this? I also tried looking at TintTypedArray.java:119. The one in gradle cache has getFont method which is v26.0.2 but in sdk/extras doesn't have which is v25.3.1. I think gradle cache code would be used for this but still it is throwing error. Please help.

Logcat:

12-06 16:52:40.516 18533-18533/com.nabta E/AndroidRuntime: FATAL EXCEPTION: main Process: com.nabta, PID: 18533 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/com.nabta-2/base.apk:classes13.dex) at android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:119) at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:208) at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:110) at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38) at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:81) at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:71) at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103) at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024) at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$WrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:280) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734) at android.view.LayoutInflater.rInflate(LayoutInflater.java:865) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828) at android.view.LayoutInflater.rInflate(LayoutInflater.java:873) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828) at android.view.LayoutInflater.inflate(LayoutInflater.java:525) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:427) at android.view.LayoutInflater.inflate(LayoutInflater.java:378) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139) at com.nabta.activity.MainActivity.onCreate(MainActivity.java:47) at android.app.Activity.performCreate(Activity.java:6977) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6816) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)

3
try to invalidate caches and restart.If problem persist revert to library version you were using earlier and rebuildMushirih
It is the same library version I was using earlier. There has been no change in this.Rushi M Thakker
@Mushirih nope. Same result.Rushi M Thakker

3 Answers

2
votes

I solved the bug. After running studio 3.0.0 I had encountered this bug. Upgrading build tools version as suggested here solved it : https://stackoverflow.com/a/47126127/3484668

2
votes

In my case, I was using Android-KTX: implementation 'androidx.core:core-ktx:0.1' in Kotlin project, and that was the cause of the error. I just removed it from build.gradle as a dependency.

P.S same answer from my post: java.lang.NoSuchMethodError: No static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)

0
votes

Updating the build gradle worked for me.

compileSdkVersion 27

targetSdkVersion 27

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:recyclerview-v7:27.0.0'
    implementation 'com.android.support:cardview-v7:27.0.0'
}