ndroid.view.InflateException: строка двоичного файла XML № 10: строка двоичного файла XML № 10: ошибка надувания класса <unknown> - PullRequest
0 голосов
/ 02 сентября 2018

эй, я пытаюсь использовать библиотеку в своем плагине Cordova, и после добавления и сборки я получаю эту ошибку при вызове

android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class <unknown>
                 Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
                 Caused by: java.lang.reflect.InvocationTargetException
                     at java.lang.reflect.Constructor.newInstance0(Native Method)
                     at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
                     at android.view.LayoutInflater.createView(LayoutInflater.java:645)
                     at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
                     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
                     at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
                     at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
                     at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
                     at android.view.View.inflate(View.java:21250)
                     at com.tapadoo.alerter.Alert.initView(Alert.java:124)
                     at com.tapadoo.alerter.Alert.<init>(Alert.java:95)
                     at com.tapadoo.alerter.Alerter.create(Alerter.java:61)
                     at cordova.plugin.Alerter.AlerterCordovaPlugin.showAlert(AlerterCordovaPlugin.java:59)
                     at cordova.plugin.Alerter.AlerterCordovaPlugin.execute(AlerterCordovaPlugin.java:30)
                     at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
                     at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
                     at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
                     at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
                     at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
                     at org.chromium.base.SystemMessageHandler.handleMessage(SourceFile:9)
                     at android.os.Handler.dispatchMessage(Handler.java:110)
                     at android.os.Looper.loop(Looper.java:203)
                     at android.os.HandlerThread.run(HandlerThread.java:61)
                  Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 35: TypedValue{t=0x2/d=0x7f0200c3 a=-1}
                     at android.content.res.TypedArray.getDrawable(TypedArray.java:928)
                     at android.view.View.<init>(View.java:4562)
                     at android.view.ViewGroup.<init>(ViewGroup.java:603)
                     at android.widget.FrameLayout.<init>(FrameLayout.java:110)
                     at android.widget.FrameLayout.<init>(FrameLayout.java:105)
                     at android.widget.FrameLayout.<init>(FrameLayout.java:100)
                     at java.lang.reflect.Constructor.newInstance0(Native Method) 
                     at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 
                     at android.view.LayoutInflater.createView(LayoutInflater.java:645) 
                     at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58) 
                     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717) 
                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785) 
                     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 
                     at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 
                     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 
                     at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 
                     at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 
                     at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 
                     at android.view.View.inflate(View.java:21250) 
                     at com.tapadoo.alerter.Alert.initView(Alert.java:124) 
                     at com.tapadoo.alerter.Alert.<init>(Alert.java:95) 
                     at com.tapadoo.alerter.Alerter.create(Alerter.java:61) 
                     at cordova.plugin.Alerter.AlerterCordovaPlugin.showAlert(AlerterCordovaPlugin.java:59) 
                     at cordova.plugin.Alerter.AlerterCordovaPlugin.execute(AlerterCordovaPlugin.java:30) 
                     at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98) 
                     at org.apache.cordova.PluginManager.exec(PluginManager.java:132) 
                     at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59) 
                     at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41) 
                     at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) 
                     at org.chromium.base.SystemMessageHandler.handleMessage(SourceFile:9) 
                     at android.os.Handler.dispatchMessage(Handler.java:110) 
                     at android.os.Looper.loop(Looper.java:203) 
                     at android.os.HandlerThread.run(HandlerThread.java:61) 

это библиотека: Alerter

Я в основном ничего не делал, просто объявил зависимость и использую пример из документации в моей Java:

 private void showAlert(String title, String message, String color, String icon, String infinite, String progress, String swipeenabled, int duration, CallbackContext callbackContext) {

            final CallbackContext CB = callbackContext;
            if (message != null && message.length() > 0 && title != null && title.length() > 0) {
                Alerter alt = Alerter.create(cordova.getActivity())
                    .setTitle(title)
                    .setText(message);

                if(color.length() >0){
                    alt.setBackgroundColorInt(Color.parseColor(color));
                }
                if(icon.length() >0 && progress.length() ==0){
                    alt.setIcon(getIconResourceId(icon)); // check out the getIconResourceId function
                }
                if(infinite.length() > 0){
                    alt.enableInfiniteDuration(true);
                }
                if(progress.length() > 0){
                    alt.enableProgress(true);
                    /*alt.setProgressColorRes(Color.parseColor(progress));*/
                }
                if(swipeenabled.length() > 0){
                    alt.enableSwipeToDismiss();
                }
                alt.setDuration(duration);
                alt.setOnHideListener(new OnHideAlertListener() {
                    @Override
                    public void onHide() {
                        CB.success("hidden");
                    }
                });
                alt.show();
            } else {
                callbackContext.error("Expected one non-empty string argument.");
            }
        }

а вот раздутый XML, это из библиотеки .jar

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/flClickShield"
             xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:background="@android:color/transparent"
             android:clickable="false">

    <FrameLayout
        android:id="@+id/flAlertBackground"
        style="@style/AlertStyle"
        android:background="@android:color/darker_gray"
        android:clickable="true"
        android:foreground="?attr/selectableItemBackground"
        tools:visibility="visible">

        <RelativeLayout
            android:id="@+id/rlContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:layout_marginTop="@dimen/alerter_padding_half"
            android:background="@null"
            android:clipChildren="false"
            android:clipToPadding="false"
            android:padding="@dimen/alerter_activity_horizontal_margin">

            <android.support.v7.widget.AppCompatImageView
                android:id="@+id/ivIcon"
                android:layout_width="@dimen/alerter_alert_icn_size"
                android:layout_height="@dimen/alerter_alert_icn_size"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:maxHeight="@dimen/alerter_alert_icn_size"
                android:maxWidth="@dimen/alerter_alert_icn_size"
                android:src="@drawable/alerter_ic_notifications"
                android:tint="@color/alert_default_icon_color"/>

            <LinearLayout
                android:id="@+id/llAlertTextContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginEnd="@dimen/alerter_activity_horizontal_margin"
                android:layout_marginLeft="@dimen/alerter_activity_horizontal_margin"
                android:layout_marginRight="@dimen/alerter_activity_horizontal_margin"
                android:layout_marginStart="@dimen/alerter_activity_horizontal_margin"
                android:layout_toEndOf="@id/ivIcon"
                android:layout_toRightOf="@id/ivIcon"
                android:background="@null"
                android:clipChildren="false"
                android:clipToPadding="false"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/tvTitle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="@style/AlertTextAppearance.Title"
                    android:visibility="gone"
                    tools:text="Title"
                    tools:visibility="visible"/>

                <TextView
                    android:id="@+id/tvText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingBottom="@dimen/alerter_padding_small"
                    android:paddingTop="@dimen/alerter_padding_small"
                    android:textAppearance="@style/AlertTextAppearance.Text"
                    android:visibility="gone"
                    tools:text="Text"
                    tools:visibility="visible"/>

            </LinearLayout>

        </RelativeLayout>

        <ProgressBar
            android:id="@+id/pbProgress"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="@dimen/alerter_progress_bar_size"
            android:layout_gravity="bottom"
            android:visibility="gone"
            tools:progress="45"/>

    </FrameLayout>

</FrameLayout>

Я использую версию библиотеки 2.0.4, так как она является наиболее стабильной по мнению создателя. Я видел решения, где проблема нехватки памяти, но здесь я не вижу ошибки нехватки памяти, поэтому мне нужна помощь здесь.

РЕДАКТИРОВАТЬ: Я попробовал ту же библиотеку в новом приложении для Android (не плагин Cordova), и она работала без проблем.

...