1

After installing BarcodeScanner.Mobile version 8.0.0.1 I get this exception when the application starts: MAUI Java.Lang.IllegalArgumentException: 'This component requires that you specify a valid TextAppearance attribute. Update your app theme to inherit from Theme.MaterialComponents (or a descendant).'

Does anyone got the same experience?

3
  • In your Android project in MainActivity, what does the ActivityAttbitute look like? Commented Apr 24, 2024 at 7:54
  • @Cheesebaron I don't have any attribute: [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] Commented Apr 24, 2024 at 13:06
  • @Cheesebaron using the default maui splash screen theme Commented Apr 24, 2024 at 16:55

2 Answers 2

1

I don't know which part of my app requires an Material design but this is what I do to fix this crash:

  1. In Platform/Android/Resources/values added styles.xml and inside added this code:
<?xml version="1.0" encoding="utf-8" ?>
<resources>
   <style name="AppTheme" parent="Theme.MaterialComponents.Light.Bridge">
       <!-- Customize your theme here. -->
       <item name="colorPrimary">@color/colorPrimary</item>
       <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
       <item name="colorAccent">@color/colorAccent</item>
   </style>
</resources>
  1. Make styles.xml Build Action AndroidResource
  2. In AndroidManifest.xml in the <manifest> tag added this lines of code:xmlns:tools="http://schemas.android.com/tools" android:theme="@style/AppTheme" tools:replace="android:theme"
  3. In MainActivity.cs replace the Theme attribute property like this: [Activity(Theme = "@style/AppTheme"....)]

All this changes fixed my problem with the Java.Lang.IllegalArgumentException

Sign up to request clarification or add additional context in comments.

2 Comments

This worked for me in .Net 9 and MAUI
This worked for me in .Net 10 and MAUI. Thanks!
0

Just adding as an answer that I when I got this error, I cleaned and built my solution and it resolved the error. Try a Clean then Build before more complicated steps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.