当前位置:  开发笔记 > 编程语言 > 正文

Xamarin链接SDK和UserAssemblies:错误膨胀类android.support.v7.widget.FitWindowsFrameLayout

如何解决《Xamarin链接SDK和UserAssemblies:错误膨胀类android.support.v7.widget.FitWindowsFrameLayout》经验,为你挑选了3个好方法。

我的应用程序没有链接工作.当我只选择Sdk Assemblies时它也能正常工作.它在调试模式下工作正常,但如果我选择链接SDk和UserAssemblies,它会开始失败.我检查了日志,我发现只有下面的内容.我谷歌四处寻找android,xamarin.android erros,人们正在谈论使用Frames.我不使用任何Android本机代码.在我的android项目中没有定义框架.我不确定这是否是xamarin.forms生产但你能帮我解决这个问题吗?

有类似的问题如下.我已经通过他们没有任何答案看起来与我的相关.即使我谷歌"android.support.v7.widget.FitWindowsFrameLayout",我也没有发现任何关于它的错误.这堂课是为了什么?我不是指这一切.错误指示我关于第23行,我检查了清单中的23,我有线.我排除它并尝试,错误没有改变.请引导我在哪里看,如果您需要更多信息,我将更新此问题.

扩展类android.support.v7.widget.Toolbar时出错?

01-24 18:54:47.344: E/AndroidRuntime(30427): java.lang.RuntimeException: Unable to start activity ComponentInfo{myapp.myapp/md5874faab2802fcbafca06095cc637d65d.MainActivity}: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class android.support.v7.widget.FitWindowsFrameLayout
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2464)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.access$900(ActivityThread.java:154)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1391)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.os.Handler.dispatchMessage(Handler.java:102)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.os.Looper.loop(Looper.java:234)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.main(ActivityThread.java:5526)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at java.lang.reflect.Method.invoke(Native Method)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    01-24 18:54:47.344: E/AndroidRuntime(30427): Caused by: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class android.support.v7.widget.FitWindowsFrameLayout
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:410)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplV7.initWindowDecorActionBar(AppCompatDelegateImplV7.java:171)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:88)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:195)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:126)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at md5874faab2802fcbafca06095cc637d65d.MainActivity.n_onCreate(Native Method)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at md5874faab2802fcbafca06095cc637d65d.MainActivity.onCreate(MainActivity.java:32)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.Activity.performCreate(Activity.java:6285)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    ... 9 more
    01-24 18:54:47.344: E/AndroidRuntime(30427): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class android.support.v7.widget.FitWindowsFrameLayout
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    ... 22 more
    01-24 18:54:47.344: E/AndroidRuntime(30427): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.FitWindowsFrameLayout" on path: DexPathList[[zip file "/data/app/myapp.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/myapp.myapp-1/lib/arm, /data/app/myapp.myapp-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.createView(LayoutInflater.java:583)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
    01-24 18:54:47.344: E/AndroidRuntime(30427):    ... 24 more
    01-24 18:54:47.344: E/AndroidRuntime(30427):    Suppressed: java.lang.ClassNotFoundException: android.support.v7.widget.FitWindowsFrameLayout
    01-24 18:54:47.344: E/AndroidRuntime(30427):        at java.lang.Class.classForName(Native Method)
    01-24 18:54:47.344: E/AndroidRuntime(30427):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
    01-24 18:54:47.344: E/AndroidRuntime(30427):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
    01-24 18:54:47.344: E/AndroidRuntime(30427):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
    01-24 18:54:47.344: E/AndroidRuntime(30427):        ... 27 more
    01-24 18:54:47.344: E/AndroidRuntime(30427):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

表现:



    
    
    
    
    
    
    
    
    
    
    
    
        
        
        
            
                
                
            
        
        
        
        
        
        
    

STYLE.XML


 
   
    
  

TOOLBAR.AXML



TABBAR.AXML



LAUNCH_LOGO.xml



  
    
  
  
    
  
  
    
    

主要活动

 [Activity(Label = "myApp",
        Icon = "@drawable/icon",
        Theme = "@style/MyTheme",
         MainLauncher = true,
        ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        public static Android.App.Activity current;

        protected override void OnCreate(Bundle bundle)
        {

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);   

Jiří Kuba.. 19

尝试更改ProGuard配置.

我找到了很好的ProGuard配置文章修复了缺少的"android.support.v7.widget.FitWindowsFrameLayout"问题(文章中的"解决方案2:ProGuard"):

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

文章中的ProGuard配置:

-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

任何ProGuard配置更改后,您应该清理解决方案.



1> Jiří Kuba..:

尝试更改ProGuard配置.

我找到了很好的ProGuard配置文章修复了缺少的"android.support.v7.widget.FitWindowsFrameLayout"问题(文章中的"解决方案2:ProGuard"):

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

文章中的ProGuard配置:

-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

任何ProGuard配置更改后,您应该清理解决方案.



2> MariusK..:

尝试从链接器中排除Android.Support v7和v4.

在XamarinStudio中: 项目选项 - > Android Build - > Linker - >忽略程序集

添加 Xamarin.Android.Support.v7.AppCompat; Xamarin.Android.Support.v4

Xamarin中Android支持库的链接器设置


这不是一个好主意,如果它作为一个生产出去,忽略整个程序集...... OP应该只在Xamarin.Android.Support.v7.AppCompat程序集中执行类型Android.Support.V7.Widget.FitWindowsFrameLayout使用自定义链接器 忽略程序集将生成一个带有许多未使用引用的未剥离程序集

3> Jonatha ANTO..:

它已被链接程序剥离,因此您可以“欺骗”并模拟如下错误用法:

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

Xamarin文档中也提供了此功能:https : //developer.xamarin.com/guides/android/advanced_topics/linking/


应该将其标记为正确答案。谢谢!
@ Umar3x可以将其放在项目中任何位置的cs文件中。
推荐阅读
女女的家_747
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有