After updating my project to android 10 I got crash on my HomeActivity , the app works fine on older versions of android but the crash happens when I use Android 10 device , I have a splash activity and it works fine but the crash happens after moving to the home activity on onCreate setContentView(R.layout.activity_home);
and here is the crash report :
E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.aia.portercustomer/com.aia.portercustomer.activity.HomeActivity}: android.view.InflateException: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3271)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: android.view.InflateException: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
Caused by: android.view.InflateException: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Field.get(java.lang.Object)' on a null object reference
at uk.co.chrisjenx.calligraphy.ReflectionUtils.getValue(ReflectionUtils.java:29)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(CalligraphyLayoutInflater.java:203)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(CalligraphyLayoutInflater.java:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:302)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:239)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.inflate(LayoutInflater.java:659)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:631)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:518)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:466)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.aia.portercustomer.activity.HomeActivity.onCreate(HomeActivity.java:408)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1300)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3246)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
2020-03-03 11:26:24.019 17491-17491/com.aia.portercustomer E/UncaughtException: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Also I tried the solutuin mention in this answer Android 10 Activity onCreate Crash by adding these dependencies to my project
// Annotation processor
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.2.0-alpha05"
// alternately - if using Java8, use the following instead of lifecycle-compiler
implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0-alpha05"
implementation "androidx.lifecycle:lifecycle-runtime:2.2.0-alpha05"
implementation "androidx.lifecycle:lifecycle-process:2.2.0-alpha05"
implementation "androidx.lifecycle:lifecycle-service:2.2.0-alpha05"
but it didn't help.
Looking into the crash logs:
Caused by: android.view.InflateException: Binary XML file line #17 in com.aia.portercustomer:layout/abc_screen_simple: Error inflating class androidx.appcompat.widget.FitWindowsLinearLayout
In your app.gradle, add the following:
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'
Read more about this Issue
The crash seems to be coming from Caligraphy library.This issue looks like what you are experiencing.
Related
I am trying to use TextInputLayout from Materials Components. Even tho my style is like this:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar", I am getting an error.
I have looked through all the similar questions on web(including stack overflow). All of them suggest to change the theme from appCompat to materialComponents, but i have already done that.
This the part of the XML that causes the error
(line 34) <com.google.android.material.textfield.TextInputLayout
android:id="#+id/til_title"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
error itself:
Caused by: android.view.InflateException: Binary XML file line #34 in com.example.happyplaces:layout/activity_add_happy_place: Binary XML file line #34 in com.example.happyplaces:layout/activity_add_happy_place: Error inflating class com.google.android.material.textfield.TextInputLayout
i have materialcomponents dependency in the build file:
implementation 'com.google.android.material:material:1.7.0-alpha03'
here is the full stack trace:
2022-08-15 10:08:31.489 16671-16671/com.example.happyplaces E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.happyplaces, PID: 16671
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.happyplaces/com.example.happyplaces.AddHappyPlaceActivity}: android.view.InflateException: Binary XML file line #34 in com.example.happyplaces:layout/activity_add_happy_place: Binary XML file line #34 in com.example.happyplaces:layout/activity_add_happy_place: Error inflating class com.google.android.material.textfield.TextInputLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3271)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: android.view.InflateException: Binary XML file line #34 in com.example.happyplaces:layout/activity_add_happy_place: Binary XML file line #34 in com.example.happyplaces:layout/activity_add_happy_place: Error inflating class com.google.android.material.textfield.TextInputLayout
Caused by: android.view.InflateException: Binary XML file line #34 in com.example.happyplaces:layout/activity_add_happy_place: Error inflating class com.google.android.material.textfield.TextInputLayout
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:854)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at com.example.happyplaces.databinding.ActivityAddHappyPlaceBinding.inflate(ActivityAddHappyPlaceBinding.java:104)
at com.example.happyplaces.databinding.ActivityAddHappyPlaceBinding.inflate(ActivityAddHappyPlaceBinding.java:98)
at com.example.happyplaces.AddHappyPlaceActivity.onCreate(AddHappyPlaceActivity.kt:12)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3246)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3410)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7397)
2022-08-15 10:08:31.491 16671-16671/com.example.happyplaces E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:241)
at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:215)
at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:143)
at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:113)
at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:467)
at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:446)
... 31 more
i cant find out what causes the error here. Any help would be very appreciated.
The problem is I was still using AppCompat library for another style. That was the cause. It took me one day to figure out.
I updated navigation component to 2.3.2 version.
In the 2.3.1 version work normally
I was going through the documentation and I did not find anything about the error or about any update in the component
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.m.marketplace, PID: 16698
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.m.marketplace/com.m.marketplace.ui.MainActivity}: android.view.InflateException: Binary XML file line #11 in com.m.marketplace:layout/activity_main: Binary XML file line #11 in com.m.marketplace:layout/activity_main: Error inflating class androidx.fragment.app.FragmentContainerView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3311)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7590)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: android.view.InflateException: Binary XML file line #11 in com.m.marketplace:layout/activity_main: Binary XML file line #11 in com.m.marketplace:layout/activity_main: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: android.view.InflateException: Binary XML file line #11 in com.m.marketplace:layout/activity_main: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: java.lang.IllegalArgumentException
at androidx.lifecycle.LifecycleRegistry.downEvent(LifecycleRegistry.java:263)
at androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:314)
at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:334)
at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145)
at androidx.lifecycle.LifecycleRegistry.setCurrentState(LifecycleRegistry.java:118)
at androidx.navigation.NavBackStackEntry.updateState(NavBackStackEntry.java:150)
at androidx.navigation.NavBackStackEntry.setMaxLifecycle(NavBackStackEntry.java:130)
at androidx.navigation.NavController.popBackStackInternal(NavController.java:325)
at androidx.navigation.NavController.navigate(NavController.java:1050)
at androidx.navigation.NavController.navigate(NavController.java:942)
at com.m.marketplace.utils.ktx.NavControllerKt.navigateSafe(NavController.kt:17)
at com.m.marketplace.utils.ktx.NavControllerKt.navigateSafe$default(NavController.kt:13)
at com.m.marketplace.utils.ktx.FragmentKt.navigate(Fragment.kt:15)
at com.m.marketplace.ui.login.view.PreviousLoginDialog.goToHome(PreviousLoginDialog.kt:119)
at com.m.marketplace.ui.login.view.PreviousLoginDialog.access$goToHome(PreviousLoginDialog.kt:28)
at com.m.marketplace.ui.login.view.PreviousLoginDialog$firstInit$1.invoke(PreviousLoginDialog.kt:111)
at com.m.marketplace.ui.login.view.PreviousLoginDialog$firstInit$1.invoke(PreviousLoginDialog.kt:28)
at com.m.marketplace.ui.login.view.PreviousLoginDialog.onCreate(PreviousLoginDialog.kt:44)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2684)
at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1175)
at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2224)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1997)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849)
E/AndroidRuntime: at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2629)
at androidx.fragment.app.FragmentManager.dispatchCreate(FragmentManager.java:2571)
at androidx.fragment.app.Fragment.onCreate(Fragment.java:1685)
at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:264)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2684)
at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1175)
at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2224)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1997)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1818)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:303)
at androidx.fragment.app.FragmentContainerView.<init>(FragmentContainerView.java:166)
at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:51)
at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:356)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:335)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1073)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1001)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:696)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:170)
at com.m.marketplace.ui.MainActivity.onCreate(MainActivity.kt:50)
at android.app.Activity.performCreate(Activity.java:7893)
at android.app.Activity.performCreate(Activity.java:7880)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3286)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3460)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7590)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
I was facing the same problem and I figured out that Android studio is not adding name tags in navigation graph. So, adding name tag in navigation graph xml worked for me.
In nav_graph.xml
<fragment
android:id="#+id/loginFragment"
android:name="com.example.MyApp.fragments.LoginFragment"
android:label="fragment_login"
tools:layout="#layout/fragment_login">
Or if you are not sure then switch to the design and in attributes tab on right side select the class name from drop-down list
If you're using Jetpack Compose change MainActivity extends to AppCompatActivity instead of CompatActivity
First make sure you have added ID to your nav graph and fragment container view. Also check fragment (declared asstart destination) does not have any instantiation issue.
When using Koin, adding android:name=".MyApplication" in application in the manifest, fixed this error and the "Accessing hidden method" warnings that were appearing before the error
'''2020-06-21 13:22:53.293 9305-9305/? E/le.androideati: Unknown bits set in runtime_flags: 0x8000
2020-06-21 13:22:54.521 9305-9305/com.example.androideatit E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.androideatit, PID: 9305
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androideatit/com.example.androideatit.MainActivity}: android.view.InflateException: Binary XML file line #40 in com.example.androideatit:layout/activity_main: Binary XML file line #40 in com.example.androideatit:layout/activity_main: Error inflating class info.hoang8f.widget.FButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: android.view.InflateException: Binary XML file line #40 in com.example.androideatit:layout/activity_main: Binary XML file line #40 in com.example.androideatit:layout/activity_main: Error inflating class info.hoang8f.widget.FButton
Caused by: android.view.InflateException: Binary XML file line #40 in com.example.androideatit:layout/activity_main: Error inflating class info.hoang8f.widget.FButton
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:854)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1006)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.example.androideatit.MainActivity.onCreate(MainActivity.java:18)
at android.app.Activity.performCreate(Activity.java:7802)
at android.app.Activity.performCreate(Activity.java:7791)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1299)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 1 to color: type=0x5 // error is here
at android.content.res.TypedArray.getColor(TypedArray.java:532)
at info.hoang8f.widget.FButton.parseAttrs(FButton.java:116)
2020-06-21 13:22:54.522 9305-9305/com.example.androideatit E/AndroidRuntime: at info.hoang8f.widget.FButton.(FButton.java:52)
... 28 more
'''
the error is here
android.view.InflateException: Binary XML file line #40 in
com.example.androideatit:layout/activity_main: Binary XML file line #40 in
com.example.androideatit:layout/activity_main: Error inflating class
info.hoang8f.widget.FButton
In the resource file loaded by MainActivity, i.e. layout/activity_main at the line 40 there is a component, info.hoang8f.widget.FButton that surely are missing libraries declared in you gradle.build file, something like
implememntation 'info.hoang8f.widget.FButton:FButton:1.0.0'
or something like that
So I would like to learn more about cameraX, the relatively new addition to the Android Jetpack library. I've been looking at an existing project on GitHub to help me understand how to set things up. However the issue is that i'm new to kotlin (project is in kotlin).
In the project: Project
there exists something called "it"
Can be seen here: Example
More specifically in the following line:
provideLayout()?.let { setContentView(it) }
"it" is repeated multiple times throughout the project as well. I just want to know what this is. Is "it" a variable? Is "it" Kotlin specific code?
Additionally, what is:
provideLayout()?.let
How does this work? What does it do?
UPDATE
Specific to CommonsWare solution (error):
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.memory.pod.debug, PID: 31521
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.memory.pod.debug/com.memory.pod.camerax.ui.home.HomeActivity}: android.view.InflateException: Binary XML file line #8 in com.memory.pod.debug:layout/activity_home: Binary XML file line #8 in com.memory.pod.debug:layout/activity_home: Error inflating class androidx.fragment.app.FragmentContainerView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: android.view.InflateException: Binary XML file line #8 in com.memory.pod.debug:layout/activity_home: Binary XML file line #8 in com.memory.pod.debug:layout/activity_home: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: android.view.InflateException: Binary XML file line #8 in com.memory.pod.debug:layout/activity_home: Error inflating class androidx.fragment.app.FragmentContainerView
Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.arindam.camerax.ui.home.permission.PermissionsFragment: make sure class name exists
at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:91)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:546)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManager$3.instantiate(FragmentManager.java:390)
at androidx.navigation.fragment.FragmentNavigator.instantiateFragment(FragmentNavigator.java:132)
at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:162)
at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:58)
at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:71)
at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:28)
at androidx.navigation.NavController.navigate(NavController.java:935)
at androidx.navigation.NavController.onGraphCreated(NavController.java:577)
at androidx.navigation.NavController.setGraph(NavController.java:534)
at androidx.navigation.NavController.setGraph(NavController.java:499)
at androidx.navigation.NavController.setGraph(NavController.java:481)
at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:237)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2684)
at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1175)
at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2224)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1997)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1818)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:303)
at androidx.fragment.app.FragmentContainerView.<init>(FragmentContainerView.java:166)
at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:51)
E/AndroidRuntime: at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:356)
at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:335)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1069)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.memory.pod.camerax.ui.base.BaseActivity.onCreate(BaseActivity.kt:11)
at android.app.Activity.performCreate(Activity.java:7825)
at android.app.Activity.performCreate(Activity.java:7814)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1306)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3245)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.ClassNotFoundException: com.arindam.camerax.ui.home.permission.PermissionsFragment
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at androidx.fragment.app.FragmentFactory.loadClass(FragmentFactory.java:47)
at androidx.fragment.app.FragmentFactory.loadFragmentClass(FragmentFactory.java:88)
... 53 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.arindam.camerax.ui.home.permission.PermissionsFragment" on path: DexPathList[[zip file "/data/app/com.memory.pod.debug-koXsvzgNs8unWof_uGUUgw==/base.apk"],nativeLibraryDirectories=[/data/app/com.memory.pod.debug-koXsvzgNs8unWof_uGUUgw==/lib/arm64, /system/lib64, /system/product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
Side not the hyperlink highlighted section is
com.memory.pod.camerax.ui.base.BaseActivity.onCreate(BaseActivity.kt:11)
Is "it" a variable?
it is a parameter passed into the lambda expression.
Taking this piece by piece...
provideLayout() is a function, returning an object.
?. is a "safe call", meaning that if the object is null, we skip the call
?.let() is a particular usage of a safe call that says "execute this lambda expression if the object is not null, and pass that object in as a parameter; if the object is null, though, skip it and let's just go have lunch"
{ setContentView(it) } is a lambda expression that is called by let() if the object returned by provideLayout() is not null, and that object is referred to in the lambda expression as it (where it is the default name of the lambda parameter, since we did not provide another name)
If we knew that provideLayout() would never return null, or if setContentView() could support null, this could be simplified as:
setContentView(provideLayout())
I made a migration to AndroidX, then I'm getting an error if I try to run the project into an emulator with API 29.
There is no problem in emulators/real devices with API 28 and previous.
java.lang.RuntimeException: Unable to start activity ComponentInfo{ [...]}: android.view.InflateException: Binary XML file line #23 in [...]:layout/abc_screen_simple_overlay_action_mode: Binary XML file line #23 in [...]:layout/abc_screen_simple_overlay_action_mode: Error inflating class androidx.appcompat.widget.FitWindowsFrameLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3409)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
If you are using Calligraphy Library, make sure to update to the 3+ version as mentioned by the author here: Issue #475
dependencies {
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'
}