androidandroid-appcompatandroidx

AndroidX causing AppCompatActivity to crash


The application was running just fine until all of a sudden this error got triggered somehow :

E/AndroidRuntime: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:543)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
    at com.thorsguild.company..Activities.MainActivity.onCreate(MainActivity.java:89)

I should mention that I just started using this library from GitHub which serve as a group toggle button and was about to test it

Q: What does this error mean and how to fix it ??

UPDATE

Entire Stack trace

2019-05-31 12:04:14.216 14753-14753/com.hablo.company.hablo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.hablo.company.hablo, PID: 14753
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hablo.company.hablo/com.hablo.company.hablo.Activities.MainActivity}: android.view.InflateException: Binary XML file line #126: Binary XML file line #111: Error inflating class com.nex3z.togglebuttongroup.button.CircularButton
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2947)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6688)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
 Caused by: android.view.InflateException: Binary XML file line #126: Binary XML file line #111: Error inflating class com.nex3z.togglebuttongroup.button.CircularButton
 Caused by: android.view.InflateException: Binary XML file line #111: Error inflating class com.nex3z.togglebuttongroup.button.CircularButton
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.nex3z.togglebuttongroup.button.CircularButton" on path: DexPathList[[zip file "/data/app/com.hablo.company.hablo-1/base.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.hablo.company.hablo-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.hablo.company.hablo-1/lib/arm64, /system/lib64, /vendor/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
    at android.view.LayoutInflater.createView(LayoutInflater.java:616)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
    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.rInflate(LayoutInflater.java:873)
    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.parseInclude(LayoutInflater.java:1011)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
    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 android.view.LayoutInflater.inflate(LayoutInflater.java:427)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:378)
2019-05-31 12:04:14.216 14753-14753/com.hablo.company.hablo E/AndroidRuntime:     at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:543)
    at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
    at com.hablo.company.hablo.Activities.MainActivity.onCreate(MainActivity.java:89)
    at android.app.Activity.performCreate(Activity.java:6912)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
    at android.app.ActivityThread.-wrap14(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6688)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

Solution

  • It looks like you have misread the class name. You are supposed to use CircularToggle but you are using CircularButton which is not there in library. You can check the sample usage mentioned on github which is as below

    <com.nex3z.togglebuttongroup.button.CircularToggle
            android:id="@+id/choice_a"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="A"/>