0

我有一个应用程序(MyApp)从另一个应用程序(pluginA)加载视图。pluginA通过实现共享库模块中提供的接口来提供视图。但是,我不断收到错误消息:

08-12 10:38:38.378 8931-8931/ca.rev.revcore W/ResourceType: For resource 0x7f0b0075, entry index(117) is beyond type entryCount(9)
08-12 10:38:38.378 8931-8931/ca.rev.revcore W/ResourceType: Failure getting entry for 0x7f0b0075 (t=10 e=117) (error -75)
08-12 10:38:38.378 8931-8931/ca.rev.revcore W/ResourceType: For resource 0x7f0b0075, entry index(117) is beyond type entryCount(9)
08-12 10:38:38.378 8931-8931/ca.rev.revcore W/ResourceType: Failure getting entry for 0x7f0b0075 (t=10 e=117) (error -75)
08-12 10:38:38.378 8931-8931/ca.rev.revcore W/ResourceType: For resource 0x7f0b0076, entry index(118) is beyond type entryCount(9)
08-12 10:38:38.378 8931-8931/ca.rev.revcore W/ResourceType: Failure getting entry for 0x7f0b0076 (t=10 e=118) (error -75)
08-12 10:38:38.378 8931-8931/ca.rev.revcore W/ResourceType: For resource 0x7f0b0076, entry index(118) is beyond type entryCount(9)
08-12 10:38:38.378 8931-8931/ca.rev.revcore W/ResourceType: Failure getting entry for 0x7f0b0076 (t=10 e=118) (error -75)  

这是提供视图时实现的接口。它在图书馆里:

public interface MyViewCreator {
    View createMyView(Context context);
}

这是 pluginA 实现接口的方式:

public class MyViewCreator extends AbstractViewCreator {

    Context mContext;

    public MyViewCreator(Context context) {
        super(context);
        mContext = context;
    }

    @Override
    public View createView() {
        LayoutInflater revInfl = LayoutInflater.from(mContext);
        final View toolBarItemsLL = revInfl.inflate(R.layout.activity_main, null, false);
        return toolBarItemsLL;
    }
}  

这是我试图在上面膨胀 的 pluginA res/layout/activity_main.xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/redLabel"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="#aa0022"
        android:gravity="center"
        android:padding="8dp"
        android:text="@string/plugin_string"
        android:textColor="@color/pluginAWhite"
        android:textSize="18sp" />

    <TextView
        android:id="@+id/blueLabel"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="#185b08"
        android:gravity="center"
        android:padding="8dp"
        android:text="@string/rev_plugin_string"
        android:textColor="@color/pluginAWhite"
        android:textSize="18sp" />
</LinearLayout>  

这一切都final View toolBarItemsLL = revInfl.inflate(R.layout.activity_main, null, false);在pluginA中中断。这是堆栈跟踪:

--------- beginning of crash
08-13 09:19:43.539 20702-20702/ca.rev.revcore E/AndroidRuntime: FATAL EXCEPTION: main
                                                                Process: com.MyApp, PID: 20702
                                                                android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class TextView
                                                                Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class TextView
                                                                Caused by: java.lang.UnsupportedOperationException: Can't convert to ComplexColor: type=0x1
                                                                    at android.content.res.ResourcesImpl.loadComplexColorForCookie(ResourcesImpl.java:879)
                                                                    at android.content.res.ResourcesImpl.loadComplexColorFromName(ResourcesImpl.java:756)
                                                                    at android.content.res.ResourcesImpl.loadColorStateList(ResourcesImpl.java:835)
                                                                    at android.content.res.Resources.loadColorStateList(Resources.java:1002)
                                                                    at android.content.res.TypedArray.getColorStateList(TypedArray.java:531)
                                                                    at android.widget.TextView.<init>(TextView.java:1076)
                                                                    at android.widget.TextView.<init>(TextView.java:704)
                                                                    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:62)
                                                                    at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:58)
                                                                    at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
                                                                    at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1029)
                                                                    at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1087)
                                                                    at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
                                                                    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
                                                                    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)
4

0 回答 0