我正在使用ChrisJenx的书法图书馆。突然今天早上我的项目开始抛出奇怪的错误。有人对此有任何想法吗?我也试着看TintTypedArray.java:119。gradle 缓存中的那个有 getFont 方法,它是 v26.0.2,但在 sdk/extras 中没有 v25.3.1。我认为gradle缓存代码将用于此,但它仍然抛出错误。请帮忙。
日志猫:
12-06 16:52:40.516 18533-18533/com.nabta E/Android运行时:致命 例外:主要 流程: com.nabta, PID: 18533 java.lang.NoSuchMethodError: no static Method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)安卓/图形/字体; 在类 Landroid/support/v4/content/res/ResourcesCompat;或其超级 类(声明 'android.support.v4.content.res.ResourcesCompat' 出现在/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.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.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.0.0 后,我遇到了这个错误。按照此处的建议升级构建工具版本解决了它: https://stackoverflow.com/a/47126127/3484668
就我而言,我在Kotlin项目中使用Android-KTX:implementation 'androidx.core:core-ktx:0.1'
,这就是导致错误的原因。我刚刚将其作为依赖项从build.gradle中删除。
附言与我的帖子相同的答案: java.lang.NoSuchMethodError: no static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)
更新构建 gradle 对我有用。
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'
}