Xamarin linking SDK and UserAssemblies: Error inflating class android.support.v7.widget.FitWindowsFrameLayout

前端 未结 4 1798
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 07:24

My app is working without linking. It works fine also when I choose Sdk Assemblies only. It works fine in debug mode as well but it start failing if I choose linking SDk and Use

相关标签:
4条回答
  • 2021-02-04 08:11

    Try to exclude Android.Support v7 and v4 from the linker.

    In XamarinStudio: Project Options -> Android Build -> Linker -> Ignore assemblies

    add Xamarin.Android.Support.v7.AppCompat;Xamarin.Android.Support.v4

    0 讨论(0)
  • 2021-02-04 08:13

    Try change ProGuard configuration.

    I found great article with ProGuard configuration which fixes the missing "android.support.v7.widget.FitWindowsFrameLayout" problem ("Solution 2: ProGuard" in the article):

    http://shaneneuville.com/firebase/proguard/2017/06/17/firebase-proguard-fun.html

    ProGuard configuration from article:

    -keep class com.google.android.gms.** { *; }
    -dontwarn com.google.android.gms.**
    -keep class com.microsoft.windowsazure.messaging.** { *; }
    -dontwarn com.microsoft.windowsazure.messaging.**
    -keep class com.google.firebase.** { *; }
    -dontwarn com.google.firebase.**
    -keep class android.support.v7.widget.** { *; }
    -dontwarn android.support.v7.widget.**
    -keep class android.support.v4.widget.Space { *; }
    -dontwarn android.support.v4.widget.Space
    

    You should clean solution after any ProGuard configuration changes.

    0 讨论(0)
  • 2021-02-04 08:15

    Actually you should be fine specifying in a custom proguard.cfg file:

    -keep class android.support.v7.widget.FitWindowsLinearLayout { *; }
    

    Create file, add above line, add it to your project and specify Build Action: ProguardConfiguration

    Clean (important)/Build/Deploy and it should work. ​​​​​​ ​​

    0 讨论(0)
  • 2021-02-04 08:20

    It's stripped by the linker so you can "trick it " and simulate a false usage like this :

    static bool falseflag = false;
    static LinkerPleaseInclude()
    {
        if (falseflag)
        {
            var ignore = new FitWindowsFrameLayout(Application.Context);
        }
    }
    

    This is available in the Xamarin documentation too : https://developer.xamarin.com/guides/android/advanced_topics/linking/

    0 讨论(0)
提交回复
热议问题