After Adding zoom sdk BottomNavigationView is crashing.
[ZoomSDKImlementation][1] https://marketplace.zoom.us/docs/sdk/native-sdks/android/build-an-app/
Here I found the problem with menu. If I removed app:menu error will gone, But menu is needed for sure.
api 'com.google.android.material:material:1.4.0'
Issue from Xml Design Tab
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="#color/colorPrimary"
app:itemIconTint="#color/bottom_nav_item_colors"
app:itemTextColor="#color/bottom_nav_item_colors"
app:labelVisibilityMode="selected"
app:menu="#menu/calf_bottom_navigation" />
at com.google.android.material.navigation.NavigationBarItemView.<init>(NavigationBarItemView.java:107)
at com.google.android.material.bottomnavigation.BottomNavigationItemView.<init>(BottomNavigationItemView.java:34)
at com.google.android.material.bottomnavigation.BottomNavigationMenuView.createNavigationBarItemView(BottomNavigationMenuView.java:197)
at com.google.android.material.navigation.NavigationBarMenuView.getNewItem(NavigationBarMenuView.java:492)
at com.google.android.material.navigation.NavigationBarMenuView.buildMenuView(NavigationBarMenuView.java:421)
at com.google.android.material.navigation.NavigationBarPresenter.updateMenuView(NavigationBarPresenter.java:72)
at com.google.android.material.navigation.NavigationBarView.inflateMenu(NavigationBarView.java:358)
at com.google.android.material.navigation.NavigationBarView.<init>(NavigationBarView.java:226)
at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:103)
at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:98)
at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:93)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:399)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:189)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:147)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:303)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1121)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1095)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:353)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:431)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:714)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$7(RenderTask.java:870)
at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$2.run(RenderExecutor.kt:187)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Stacktrace when run the app
2022-02-17 16:24:16.909 6448-6448/com.lakshya.academy E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.lakshya.academy, PID: 6448
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lakshya.academy/com.nuveda.calf.ui.participant.activity.ParticipantHomeActivity}: android.view.InflateException: Binary XML file line #115: Binary XML file line #115: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #115: Binary XML file line #115: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #115: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
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.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:699)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
at com.nuveda.calf.ui.participant.activity.ParticipantHomeActivity.onCreate(ParticipantHomeActivity.kt:82)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.ViewGroup.getPaddingBottom()' on a null object reference
at com.google.android.material.navigation.NavigationBarItemView.<init>(NavigationBarItemView.java:107)
at com.google.android.material.bottomnavigation.BottomNavigationItemView.<init>(BottomNavigationItemView.java:34)
at com.google.android.material.bottomnavigation.BottomNavigationMenuView.createNavigationBarItemView(BottomNavigationMenuView.java:197)
at com.google.android.material.navigation.NavigationBarMenuView.getNewItem(NavigationBarMenuView.java:492)
at com.google.android.material.navigation.NavigationBarMenuView.buildMenuView(NavigationBarMenuView.java:421)
2022-02-17 16:24:16.910 6448-6448/com.lakshya.academy E/AndroidRuntime: at com.google.android.material.navigation.NavigationBarPresenter.updateMenuView(NavigationBarPresenter.java:72)
at com.google.android.material.navigation.NavigationBarView.inflateMenu(NavigationBarView.java:358)
at com.google.android.material.navigation.NavigationBarView.<init>(NavigationBarView.java:226)
at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:103)
at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:98)
at com.google.android.material.bottomnavigation.BottomNavigationView.<init>(BottomNavigationView.java:93)```
[1]: https://marketplace.zoom.us/docs/sdk/native-sdks/android/build-an-app
I've created a fresh new app using the Empty Activity Template. Then I went to the almost empty main_activity.xml and pasted your BottomSheet.
I added your dependency to build.gradle.
I fixed the missing things:
constrains so the COnstraintLayout doesn't scream at me.
Colors, I picked random colors that come with Android.
Menu: you didn't supply this one, but I have the impression this is where your problem could be. Mine is empty, as I don't know what's in yours.
Theme: I changed the default from the template (DayNight) to Light.
And... it runs.
So, I'd start from this empty project, adding your bits one by one until you figure out what is crashing your inflation process.
Why do I think your menu is involved?
If you look at your stacktrace, the BottomNavigationView is calling its constructor init() and part of this involves inflating the menu items:
at NavigationBarItemView.<init>(NavigationBarItemView.java:107)
at BottomNavigationItemView.<init>(BottomNavigationItemView.java:34)
at BottomNavigationMenuView.createNavigationBarItemView(BottomNavigationMenuView.java:197)
at NavigationBarMenuView.getNewItem(NavigationBarMenuView.java:492)
at NavigationBarMenuView.buildMenuView(NavigationBarMenuView.java:421)
at.NavigationBarPresenter.updateMenuView(NavigationBarPresenter.java:72)
at NavigationBarView.inflateMenu(NavigationBarView.java:358)
at NavigationBarView.<init>(NavigationBarView.java:226)
Here's my sample project running:
If you are still facing this issue, it is probably being caused due to a custom implementation of an older version of design_bottom_navigation_item.xml file either in your codebase or in the SDK. This file was updated in version 1.3.0 and again in 1.4.0 of Material Component Library. Overriding it with an incompatible version will cause the app to crash.
I work on an app with kotlin and androidx and i create setting class was working normally till it crash and give me that error in logcat
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.alserdar.evana, PID: 9425
android.view.InflateException: Binary XML file line #18: Binary XML file line #18: Error inflating class androidx.recyclerview.widget.RecyclerView
Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class androidx.recyclerview.widget.RecyclerView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:658)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at androidx.preference.PreferenceFragmentCompat.onCreateRecyclerView(PreferenceFragmentCompat.java:541)
at androidx.preference.PreferenceFragmentCompat.onCreateView(PreferenceFragmentCompat.java:208)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2698)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:310)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1185)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1354)
at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1432)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1495)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:447)
at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:2167)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1990)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1945)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1847)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2621)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2569)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:201)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1419)
at android.app.Activity.performStart(Activity.java:7479)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3454)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199)
at android.os.Handler.dispatchMessage(Handler.java:112)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Caused by: java.lang.IllegalArgumentException: Providing a LayoutTransition into RecyclerView is not supported. Please use setItemAnimator() instead for animating changes to the items in this RecyclerView
at androidx.recyclerview.widget.RecyclerView.setLayoutTransition(RecyclerView.java:2313)
at android.view.ViewGroup.initFromAttributes(ViewGroup.java:730)
at android.view.ViewGroup.<init>(ViewGroup.java:662)
at android.view.ViewGroup.<init>(ViewGroup.java:655)
i tried to implement
implementation "androidx.legacy:legacy-preference-v14:1.0.0"
and implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
i really tried every thing and i don't know from where that error coming i don't even use the recycleview
i tried to remove that line code supportFragmentManager
.beginTransaction()
.replace(R.id.settings, HeaderFragment())
.commit()
it open the class but without the views ..
my header class is that
<androidx.preference.PreferenceScreen
xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
app:key="gifts"
app:title="Gifts"
app:icon="#mipmap/gift"
app:fragment="com.alserdar.evana.b_home_stuff.setting_stuff.SettingsActivity$Gifts"/>
<Preference
app:key="share"
app:title="Share"
app:icon="#mipmap/share"
app:fragment="com.alserdar.evana.b_home_stuff.setting_stuff.SettingsActivity$Share"/>
<Preference
app:key="buy_pin"
app:title="Change Pin"
app:icon="#mipmap/pin_code"
app:fragment="com.alserdar.evana.b_home_stuff.setting_stuff.SettingsActivity$SyncFragment"/>
<Preference
app:key="link_accounts"
app:title="Link Accounts"
app:icon="#mipmap/link"
app:fragment="com.alserdar.evana.b_home_stuff.setting_stuff.SettingsActivity$LinkAccounts"/>
<Preference
app:key="contact_us"
app:title="Contact Us"
app:icon="#mipmap/messages"
app:fragment="com.alserdar.evana.b_home_stuff.setting_stuff.SettingsActivity"/>
<Preference
app:key="add_country"
app:title="Add Country"
app:icon="#mipmap/plus"
app:fragment="com.alserdar.evana.b_home_stuff.setting_stuff.SettingsActivity"/>
Problem :
Hey everyone, I have a straightforward issue.
I have used androidx.slidingpanelayout.widget.SlidingPaneLayout in AndroidX before, and it worked perfectly fine.
But now, in my another application, Android-Studio is giving me an error which basically says it is having problems inflating SlidingPaneLayout class.
What I did :
I have checked every dependency and also compared it with my previous app that uses this.
I rebuilt my project many many times and also cleaned it (Build > Clean Project).
I used previous versions of material-design dependency and compiled my project with them, but nothing changed.
The dependencies I've used :
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0-alpha10'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
Note that I've also tried to switch back to alpha09 which I used in my other app, but here it did nothing.
Error :
I have simply copied and pasted the whole error below.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: afm.scheduler, PID: 5241
java.lang.RuntimeException: Unable to start activity ComponentInfo{afm.scheduler/afm.scheduler.ChatActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.slidingpanelayout.widget.SlidingPaneLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.slidingpanelayout.widget.SlidingPaneLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.slidingpanelayout.widget.SlidingPaneLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.slidingpanelayout.widget.SlidingPaneLayout" on path: DexPathList[[zip file "/data/app/afm.scheduler-pdmC1V-CHlc9Wtgy6E_N0A==/base.apk"],nativeLibraryDirectories=[/data/app/afm.scheduler-pdmC1V-CHlc9Wtgy6E_N0A==/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:171)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:610)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.inflate(LayoutInflater.java:496)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at afm.scheduler.ChatActivity.onCreate(ChatActivity.java:36)
at android.app.Activity.performCreate(Activity.java:7224)
at android.app.Activity.performCreate(Activity.java:7213)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
I/afm.scheduler: ProcessProfilingInfo new_methods=0 is saved saved_to_disk=0 resolve_classes_delay=8000
Process 5241 terminated.
Goal :
I just want be able to use SlidingPaneLayout in my existing AndroidX application.
Just adding "implementation 'androidx.slidingpanelayout:slidingpanelayout:1.1.0'" in your build.gradle file.
I just made a migration to androidx through Android Studio menu option Refactor -> Refactor to AndroidX
I'm getting the following error:
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
Any idea?
Stacktrace:
2018-10-19 00:25:58.128 28131-28131/com.midounoo.midounoo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.midounoo.midounoo, PID: 28131
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.midounoo.midounoo/com.midounoo.midounoo.Base.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6255)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.ConstraintLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.ConstraintLayout" on path: DexPathList[[zip file "/data/app/com.midounoo.midounoo-2/base.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.midounoo.midounoo-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.midounoo.midounoo-2/lib/arm64, /system/lib64, /vendor/lib64, /system/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:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.midounoo.midounoo.Base.MainActivity.onCreate(MainActivity.java:43)
at android.app.Activity.performCreate(Activity.java:6666)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2789)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1527)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6255)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
I solve my problem by changing all occurrences of
androidx.constraintlayout.ConstraintLayout
to
androidx.constraintlayout.widget.ConstraintLayout
Add androidx.constraintlayout.widget.ConstraintLayout to the dependencies:
dependencies {
// https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
It's available on mavenCentral().
I had the same problem, I resolved it as follows:
In your dependecies if you have added
implementation 'androidx.constraintlayout:constraintlayout:1.x.x' that is correct
but in your xml layout file you have to use the widget as
androidx.constraintlayout.widget.ConstraintLayout
build.gradle => check dependencies version
implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
to change
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
solved the problem
I has same issue after:
migration support library to androidx;
increment targetSdkVesrsion to 29;
I also use:
implementation "uk.co.chrisjenx:calligraphy:2.3.0"
I tried all posts from this question, but none success.
I fix it by adding one string .disableCustomViewInflation() to Calligraphy init:
#Override
public void onCreate() {
super.onCreate();
// ...
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Sans-Regular.ttf")
.setFontAttrId(R.attr.fontPath)
.disableCustomViewInflation() // <----- this fix
.build());
// ...
}
I hope next release of Calligraphy (Christopher Jenkins thanks for your great job) will fix it inside too.
If after adding mavenCentral() as a repository in your Gradle file and changing androidx.constraintlayout.ConstraintLayout to androidx.constraintlayout.widget.ConstraintLayout didn't solve your problem then try doing Invalidate cache and restart from the file menu. It worked for me.
make sure your project migrate to androidx completely , In my case I found :
<android.support.constraint.ConstraintLayout
instead of
<androidx.constraintlayout.widget.ConstraintLayout
So change it and my problem fixed!
After clicking on Refactor -> Migrate to AndroidX , Make sure your all dependencies in the build.gradle(Module:app) is marked to the newest version.
If its not, dependency will appear in yellow highlighted color and you can change it by hovering the mouse over it.
Secondly,
Change the ConstraintLayout tag in all XML layout files to
androidx.constraintlayout.widget.ConstraintLayout
For more safer option, clean your project and sync it again after the above steps.
Make Sure you have added the dependency for constraint layout
dependencies {
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
and have made the changes to
<androidx.constraintlayout.widget.ConstraintLayout instead of
<android.support.constraint.ConstraintLayout
I copied and pasted an existing ConstraintLayout tag from the xml, which was causing the issue for me. Simply deleting, and re-adding the ConstraintLayout tags in AndroidStudio from scratch fixed the issue for me.
Make sure to change to
<androidx.constraintlayout.widget.ConstraintLayout
instead of
<android.support.constraint.ConstraintLayout
and
<androidx.constraintlayout.widget.Barrier
instead of
<android.support.constraint.Barrier
I had this issue with Android Studio 4.0. I used android studio 4.0 for a couple of days without problems. Seemingly out of nowhere the designer view stopped working.
I could only fix this by uninstalling android studio and installing the newest android studio version.
Since my implementation was already androidx.constraintlayout.ConstraintLayout, just using a Clean Project solved my problem.
yepp.
mavenCentral() and correct dependencies solve my same problems
I had a similar error.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.MainActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2757)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2818)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6393)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:652)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:812)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.myapp.MainActivity.onCreate(MainActivity.java:23)
at android.app.Activity.performCreate(Activity.java:6858)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2710)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2818)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1557)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6393)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/constraintlayout/widget/R$styleable;
at androidx.constraintlayout.widget.ConstraintLayout.init(ConstraintLayout.java:590)
at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:567)
... 23 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.widget.R$styleable" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp-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)
... 25
Following the recomendations:
add androidx.constraintlayout.ConstraintLayout to the dependencies:
dependencies {
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
}
And the repository mavenCentral().
Works for me. I could compile the APK.
I updated the dependency, yet it did not resolve the error.
Then I did a clean project and build and it is working now.
Find all default before to click Refactor -> Refactor to AndroidX
Open this https://developer.android.com/jetpack/androidx/migrate/class-mappings and find "android.support.v4.widget.DrawerLayout". In same line AndroidX class name is "androidx.drawerlayout.widget.DrawerLayout" copy it.
Replace all "android.support.v4.widget.DrawerLayout" to "androidx.drawerlayout.widget.DrawerLayout" in your project"s code, layout and menu. After all replace it will work.
I mean find mapping and use it in whole project.
change your constraint layout dependancy to implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
None of the solution worked for me, looking closely at the exception stack trace:
Caused by: android.content.res.Resources$NotFoundException: Resource "com.XXX.XXX:drawable/walpaper" (7f0800aa) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0800aa a=-1 r=0x7f0800aa}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2690)
at android.content.res.Resources.loadDrawable(Resources.java:2614)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.view.View.<init>(View.java:3791)
at android.view.ViewGroup.<init>(ViewGroup.java:524)
at android.view.ViewGroup.<init>(ViewGroup.java:520)
at android.view.ViewGroup.<init>(ViewGroup.java:516)
drawable background image loading was causing some issue on my old test device (newer devices load it just fine). Just removed the following line from my layouts it is working fine now, need to figure out how to set the background now..
android:background="#drawable/walpaper"
I had the issue with ImageFilterView converting jpg images to png solved the issue for me.
I'm having some problem with BottomNavigationView from design support library.
I am using it in my activity_main.xml:
<android.support.design.widget.BottomNavigationView
android:id="#+id/navigation"
app:itemIconSize="16dp"
app:labelVisibilityMode="labeled"
app:itemTextColor="#color/white"
app:itemIconTint="#color/white"
app:itemBackground="#color/medium_purple"
app:menu="#menu/main"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
The app crashes when inflating that xml. The full stack trace of the exception is below:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.frolo.musp.dev/com.alexfrolov.mp.main.MainActivity}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class android.support.design.widget.BottomNavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2814)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:822)
Caused by: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:651)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:734)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:867)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:828)
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.alexfrolov.mp.main.MainActivity.onCreate(MainActivity.java:165)
at android.app.Activity.performCreate(Activity.java:7074)
at android.app.Activity.performCreate(Activity.java:7065)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:822)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:220)
at android.content.res.MiuiResourcesImpl.getValue(MiuiResourcesImpl.java:93)
at android.content.res.Resources.getColorStateList(Resources.java:1034)
at android.content.Context.getColorStateList(Context.java:631)
at android.support.v7.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:67)
at android.support.design.internal.BottomNavigationMenuView.createDefaultColorStateList(BottomNavigationMenuView.java:467)
at android.support.design.internal.BottomNavigationMenuView.<init>(BottomNavigationMenuView.java:101)
at android.support.design.internal.BottomNavigationMenuView.<init>(BottomNavigationMenuView.java:86)
The versions of all support libs and the version of compileSdk are same. I really don't understand what a hell is that. Can anybody explain me please?
Thanks
I had this problem and it baffled me for a day or so. Basically, the BottomNav wants a colorstatelist defined for textColorSecondary in your theme as opposed to a just plain color. So I went from:
<style name="MTheme" parent="Theme.MaterialComponents.Light.Bridge">
...
<item name="android:textColorSecondary">#295055</item>
to
<style name="MTheme" parent="Theme.MaterialComponents.Light.Bridge">
...
<item name="android:textColorSecondary">#color/secondary_textcolor</item>
where secondary_textcolor equals
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:color="#295055"/>
<item android:state_enabled="false" android:color="#color/disabled"/>
</selector>
I wasted a lot of time adding and removing dependencies trying to find this solution.
The problem is in your question title
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
It means that you are using a resource that is not existent. I cannot know which it is but this is how you will fix. Go to the file #menu/main and remove all attributes for icons. You can leave the text. Add one by one to check which one is the problem. It is most likely to be that your icons have been mistakenly placed inside the folder drawable-24 instead of drawable or a higher android API folder than the one you are testing on. Sometimes we make those mistakes.
Also note that some attributes only apply starting a certain android API. Consider checking the attributes starting with app.
app:itemTextColor="#color/white"
app:itemIconTint="#color/white"
app:itemBackground="#color/medium_purple"