安装 BarcodeScanner.Mobile 版本 8.0.0.1 后,应用程序启动时出现此异常:
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).'
有人有同样经历吗?
我不知道我的应用程序的哪一部分需要材质设计,但这就是我修复此崩溃的方法:
<?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>
styles.xml
构建动作 AndroidResource
AndroidManifest.xml
中的<manifest>
标签中添加了这行代码:xmlns:tools="http://schemas.android.com/tools" android:theme="@style/AppTheme" tools:replace="android:theme"
MainActivity.cs
中替换 Theme
属性,如下所示:
[Activity(Theme = "@style/AppTheme"....)]
所有这些更改都解决了我的问题
Java.Lang.IllegalArgumentException
,但在启动屏幕上再次运行应用程序后再次崩溃,但有例外:
**System.ArgumentException:** 'Cannot bind to the target method because its signature is not compatible with that of the delegate type.'
[AppCenterXamarinCrashes] Unhandled Exception from source=AppDomain
[AppCenterXamarinCrashes] System.ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type.
[AppCenterXamarinCrashes] at System.Delegate.CreateDelegate(Type type, Type target, String method, Boolean ignoreCase, Boolean throwOnBindFailure)
[AppCenterXamarinCrashes] at System.Delegate.CreateDelegate(Type type, Type target, String method)
[AppCenterXamarinCrashes] at Android.Runtime.AndroidTypeManager.RegisterNativeMembers(JniType nativeClass, Type type, ReadOnlySpan`1 methods) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/AndroidRuntime.cs:line 557 ```