Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodException: addFontWeightStyle Error

I am getting an exception which is thrown when I set the contentView of the MainActivity to the XML below. It already worked fine, but after some hours of implementation on other Activities I am getting this error. I cant reproduce the cause of this error. Maybe a change of min SDK Version or the implementation of a new library.

I am using the following libraries:

implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
    implementation 'com.google.android.material:material:1.0.0-beta01'
    implementation 'me.gujun.android.taggroup:library:1.4@aar'
    implementation 'com.squareup.okhttp3:okhttp:3.2.0'
    implementation 'com.aurelhubert:ahbottomnavigation:2.3.4'
    implementation 'com.github.feeeei:CircleSeekbar:v1.1.2'
    implementation 'me.gujun.android.taggroup:library:1.4@aar'
    implementation 'com.github.igalata:Bubble-Picker:v0.2.4'
    implementation 'com.ogaclejapan.arclayout:library:1.1.0@aar'

2019-03-01 10:09:43.145 32685-32685/ I/zygote64: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.germany.alexander.example -E2CMDM5ILl_awcv3JvuuHg==/base.apk", zip file "/data/app/com.germany.alexander.example -E2CMDM5ILl_awcv3JvuuHg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.germany.alexander.example -E2CMDM5ILl_awcv3JvuuHg==/split_lib_resources_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/s 2019-03-01 10:09:43.146 32685-32685/com.germany.alexander.example I/zygote64: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/base.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_resources_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/s 2019-03-01 10:09:43.147 32685-32685/com.germany.alexander.example I/zygote64: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/base.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_dependencies_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_resources_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_0_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_1_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_2_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_3_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/split_lib_slice_4_apk.apk", zip file "/data/app/com.germany.alexander.example-E2CMDM5ILl_awcv3JvuuHg==/s 2019-03-01 10:09:43.200 32685-32685com.germany.alexander.example E/TypefaceCompatApi21Impl: java.lang.NoSuchMethodException java.lang.NoSuchMethodException: addFontWeightStyle [class java.lang.String, int, boolean] at java.lang.Class.getMethod(Class.java:2068) at java.lang.Class.getMethod(Class.java:1690) at androidx.core.graphics.TypefaceCompatApi21Impl.(TypefaceCompatApi21Impl.java:74) at androidx.core.graphics.TypefaceCompat.(TypefaceCompat.java:49) at androidx.core.graphics.TypefaceCompat.create(TypefaceCompat.java:190) at androidx.appcompat.widget.AppCompatTextView.setTypeface(AppCompatTextView.java:576) at androidx.appcompat.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:217) at androidx.appcompat.widget.AppCompatTextView.(AppCompatTextView.java:103) at androidx.appcompat.widget.AppCompatTextView.(AppCompatTextView.java:93) at androidx.appcompat.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:182) at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103) at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1267) at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1317) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:772) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate(LayoutInflater.java:866) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:470) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:141) at com.germany.alexander.example.MainActivity.onCreate(MainActivity.java:40) at android.app.Activity.performCreate(Activity.java:7183) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6938) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?android:attr/actionBarSize"
            android:background="@android:color/white"
            android:elevation="4dp"
            android:theme="@style/ToolBarStyle"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light">


            <TextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="Title"
                android:textColor="@android:color/black"
                android:textSize="18sp"
                android:textStyle="bold"
                android:visibility="visible" />

            <ImageView
                android:id="@+id/toolbarSearch"
                android:layout_width="30dp"
                android:layout_height="match_parent"
                android:layout_gravity="right"
                android:layout_marginRight="15dp"
                app:srcCompat="@drawable/search" />

            <EditText
                android:id="@+id/editText"
                style="@style/Base.Widget.MaterialComponents.TextInputEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginRight="5dp"
                android:ems="10"
                android:inputType="textPersonName"
                android:textColor="@android:color/black"
                android:textCursorDrawable="@null"
                android:visibility="gone"
                app:backgroundTint="@android:color/black" />

        </androidx.appcompat.widget.Toolbar>

        <FrameLayout
            android:id="@+id/your_placeholder"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="?android:attr/actionBarSize"></FrameLayout>

        <com.aurelhubert.ahbottomnavigation.AHBottomNavigation
            android:id="@+id/bottom_navigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom" />

    </androidx.coordinatorlayout.widget.CoordinatorLayout>
like image 219
Alex9677 Avatar asked Aug 23 '26 19:08

Alex9677


2 Answers

In the app gradle file,

Replace:

implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'

with:

implementation 'androidx.appcompat:appcompat:1.0.2'
like image 165
Alexei Artsimovich Avatar answered Aug 26 '26 10:08

Alexei Artsimovich


The issue is already tracked here: https://issuetracker.google.com/issues/124274577

This has already been solved by https://android-review.googlesource.com/c/platform/frameworks/support/+/878553/ and is going to be available in a future release. Currently the exception is thrown but it doesn't affect the app (the typeface still loads correctly), everything should still work fine.

You can wait for a future release of AppCompat, go back to an older stable release or continue using this release for testing if it doesn't crash.

like image 44
Eugen Pechanec Avatar answered Aug 26 '26 08:08

Eugen Pechanec



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!