链接SDK和UserAssemblies

链接SDK和UserAssemblies

本文介绍了Xamarin链接SDK和UserAssemblies:膨胀类android.support.v7.widget.FitWindowsFrameLayout时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用正在运行,但未链接.当我仅选择"SDK组件"时,它也可以正常工作.它在调试模式下也可以正常工作,但是如果我选择链接SDk和UserAssemblies,它就会开始失败. 我检查了日志,只发现下面的内容.我到处都在搜索android,xamarin.android erros和人们在谈论使用Frames.我不使用任何Android本机代码.我的android项目中没有定义框架.我不确定这是否是xamarin.forms产生的,但是您能帮我解决这个问题吗?

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 UserAssemblies. I checked the logs and i find only what is below. I google all around for android, xamarin.android erros and people are talking about using Frames. I dont use any android native code. there is no frame defined in my android project. i am not sure if that is xamarin.forms producing but Can you please help me how to solve this problem?

还有类似的问题,如下所示.我已经经历了他们,没有答案与我的答案有关.即使当我用谷歌搜索"android.support.v7.widget.FitWindowsFrameLayout"时,我也没有发现任何错误.这堂课是做什么用的?我指的不是全部.错误指示我关于第23行,我检查清单中的第23行,这里有行<receiver android:name="com.onesignal.NotificationOpenedReceiver" />.我排除它并尝试,错误没有改变.请带我到哪里去看看,如果您需要更多信息,我将更新此问题.

there are similar questions like below. I already went through them no answer looks like related to my one. Even when I google "android.support.v7.widget.FitWindowsFrameLayout", I dont find any error about it. what is this class for? I am not referring to it all.Error indicates me about line number 23 and I check the 23 in my manifest, there I have the line <receiver android:name="com.onesignal.NotificationOpenedReceiver" />. I excluded it and tried, error didnt change. Please lead me where should I look, if you need more information, I am going to update this question.

膨胀类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

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="myapp.myapp" android:versionCode="1"
 android:versionName="1.0" android:installLocation="preferExternal">
    <uses-sdk android:minSdkVersion="15" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
    <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
    <application android:label="myApp" android:icon="@drawable/icon">
        <meta-data android:name="onesignal_app_id" android:value="346457689798" />
        <meta-data android:name="onesignal_google_project_number" android:value="134654677" />
        <receiver android:name="com.onesignal.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.companyname.example.shared.application.droid" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.onesignal.NotificationOpenedReceiver" />
        <service android:name="com.onesignal.GcmIntentService" />
        <service android:name="com.onesignal.SyncService" android:stopWithTask="false" />
        <activity android:name="com.onesignal.PermissionsActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />
    </application>
</manifest>

STYLE.XML

STYLE.XML

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <style name="MyTheme" parent="MyTheme.Base">
    <item name="android:windowBackground">@drawable/launch_logo</item>
  </style>
  <style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">#00FFFF</item>
    <item name="colorPrimaryDark">#1976D2</item>
    <item name="colorAccent">#FF4081</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
  </style>
  <style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorAccent">#FF4081</item>
    <item name="windowNoTitle">true</item>
  </style>
</resources>

TOOLBAR.AXML

TOOLBAR.AXML

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

TABBAR.AXML

TABBAR.AXML

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:tabIndicatorColor="@android:color/white"
    app:tabGravity="fill"
    app:tabMode="fixed" />

LAUNCH_LOGO.xml

LAUNCH_LOGO.xml

<?xml version="1.0" encoding="utf-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
  <item>
    <color android:color="@color/background_material_light"/>
  </item>
  <item>
    <bitmap
        android:src="@drawable/ic_splash"
        android:tileMode="disabled"
        android:gravity="center"/>
  </item>
  <item>
    <bitmap
        android:src="@drawable/splash_text"
        android:tileMode="disabled"
        android:gravity="bottom"
        />
  </item>
</layer-list>

维护性

 [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);

推荐答案

尝试更改ProGuard配置.

Try change ProGuard configuration.

我发现了一篇很棒的文章,其中包含ProGuard的配置,可解决丢失的"android.support.v7.widget.FitWindowsFrameLayout" 问题(本文中的解决方案2:ProGuard"):

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配置:

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

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

You should clean solution after any ProGuard configuration changes.

这篇关于Xamarin链接SDK和UserAssemblies:膨胀类android.support.v7.widget.FitWindowsFrameLayout时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:00