android.view.InflateException:二进制XML文件行#16:错误导致类<unknown>

时间:2015-07-31 17:05:56

标签: java android android-layout android-fragments

有关可能导致此错误的原因的任何见解? Logcat在下面。它一直很好,最近才开始出现这个问题。其他搜索表明它可能与缺乏资源或错误导入的包名相关,但我不认为是这种情况。 Crashlytics显示有足够的​​RAM可用,导入没有改变。

       android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
       at android.view.LayoutInflater.createView(LayoutInflater.java:640)
       at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
       at android.view.View.inflate(View.java:19573)
       at com.makerbot.mobile.fragment.printing.status.PrinterLoadingFileFragment.onCreateView(PrinterLoadingFileFragment.java:34)
       at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
       at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
       at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
       at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
       at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
       at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
       at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
       at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:447)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment.updateView(PrinterStatusViewPagerFragment.java:585)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment.onPrinterStateNotificationReceived(PrinterStatusViewPagerFragment.java:607)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment$1.onReceive(PrinterStatusViewPagerFragment.java:236)
       at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
       at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
       at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5942)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Logcat继续:

       Caused by: java.lang.reflect.InvocationTargetException
       at java.lang.reflect.Constructor.newInstance(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at android.view.LayoutInflater.createView(LayoutInflater.java:614)
       at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:821)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
       at android.view.View.inflate(View.java:19573)
       at com.makerbot.mobile.fragment.printing.status.PrinterLoadingFileFragment.onCreateView(PrinterLoadingFileFragment.java:34)
       at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
       at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
       at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
       at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
       at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
       at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
       at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
       at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:447)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment.updateView(PrinterStatusViewPagerFragment.java:585)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment.onPrinterStateNotificationReceived(PrinterStatusViewPagerFragment.java:607)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment$1.onReceive(PrinterStatusViewPagerFragment.java:236)
       at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
       at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
       at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5942)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)

还有一些:

Caused by: java.lang.OutOfMemoryError
       at android.graphics.BitmapFactory.nativeDecodeAsset(BitmapFactory.java)
       at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:516)
       at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:361)
       at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:796)
       at android.content.res.Resources.loadDrawable(Resources.java:2004)
       at android.content.res.Resources.getDrawable(Resources.java:674)
       at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:282)
       at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:896)
       at android.graphics.drawable.Drawable.createFromXml(Drawable.java:833)
       at android.content.res.Resources.loadDrawable(Resources.java:1989)
       at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
       at android.widget.ImageView.(ImageView.java:120)
       at android.widget.ImageView.(ImageView.java:110)
       at java.lang.reflect.Constructor.constructNative(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
       at android.view.LayoutInflater.createView(LayoutInflater.java:587)
       at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
       at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
       at android.view.View.inflate(View.java:16744)
       at com.makerbot.mobile.fragment.printing.status.PrinterLoadingFileFragment.onCreateView(PrinterLoadingFileFragment.java:34)
       at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
       at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
       at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
       at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
       at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
       at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
       at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
       at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
       at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:447)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment.updateView(PrinterStatusViewPagerFragment.java:585)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment.onPrinterStateNotificationReceived(PrinterStatusViewPagerFragment.java:607)
       at com.makerbot.mobile.fragment.printing.PrinterStatusViewPagerFragment$1.onReceive(PrinterStatusViewPagerFragment.java:236)
       at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
       at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
       at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:5171)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564)
       at dalvik.system.NativeStart.main(NativeStart.java)

下面的XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:mobile="http://schemas.android.com/apk/res-auto"
              xmlns:tools="http://schemas.android.com/tools"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@color/mobile_background_dark"
    >

    <com.makerbot.ui.widget.AspectRatioRelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        mobile:aspectRatio="1.3333"
        >
        <ImageView
            android:id="@+id/animationImageView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/animation_cloudslice"
            android:scaleType="fitCenter"
            />
    </com.makerbot.ui.widget.AspectRatioRelativeLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="@dimen/printer_status_bar_height"
        >

        <ProgressBar
            android:id="@+id/progressBar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            style="?android:attr/progressBarStyleHorizontal"
            android:progress="33"
            android:max="100"
            android:progressDrawable="@drawable/progress_printer_slice"/>

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:gravity="top"
            android:layout_marginLeft="@dimen/printer_status_bar_side_padding"
            >
            <com.makerbot.mobile.widget.antenna.AntennaTextView
                android:id="@+id/slice_percent_complete"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                mobile:typeface="antenna_black"
                android:textSize="@dimen/printer_status_bar_text_size"
                android:textColor="@android:color/white"
                tools:text="33"/>

            <com.makerbot.mobile.widget.antenna.AntennaTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="3dp"
                android:layout_toRightOf="@+id/slice_percent_complete"
                mobile:typeface="antenna_black"
                android:textSize="14sp"
                android:textColor="@android:color/white"
                android:text="%"
                />
        </RelativeLayout>
    </FrameLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        >
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="center"
            >
            <com.makerbot.mobile.widget.antenna.AntennaTextView
                android:id="@+id/status_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                mobile:typeface="antenna_regular"
                android:textSize="14sp"
                android:textColor="@android:color/white"
                android:layout_gravity="center_horizontal"
                android:text="@string/loading_print_file"/>

            <com.makerbot.mobile.widget.antenna.AntennaTextView
                android:id="@+id/time_elapsed"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginTop="8dp"
                mobile:typeface="antenna_black"
                android:textSize="32sp"
                android:textColor="@android:color/white"
                android:layout_gravity="center_horizontal"
                android:text="00:00:00"/>

            <com.makerbot.mobile.widget.antenna.AntennaTextView
                android:id="@+id/time_remaining"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                mobile:typeface="antenna_black"
                android:textSize="14sp"
                android:textColor="@color/mobile_text_dark"
                android:layout_gravity="center_horizontal"
                android:text="@string/about_remaining"/>
        </LinearLayout>
    </FrameLayout>


</LinearLayout>

对应的Java文件:

    package com.makerbot.mobile.fragment.printing.status;

import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.makerbot.api.printing.model.PrinterResponse;
import com.makerbot.api.printing.model.PrinterStateNotification;
import com.makerbot.api.printing.model.PrinterSystemNotification;
import com.makerbot.mobile.R;

/**
 * Created by david on 1/30/15.
 */
public class PrinterLoadingFileFragment extends PrinterStatusFragment {
    private ProgressBar progressBar;
    private TextView progressTextView;
    private TextView statusTextView;

    public static final String TAG = PrinterLoadingFileFragment.class.getSimpleName();

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = View.inflate(getActivity(), R.layout.fragment_printer_status_load_file, null);

        ImageView imageView = (ImageView)view.findViewById(R.id.animationImageView);
        ((AnimationDrawable)imageView.getDrawable()).start();

        progressBar = (ProgressBar)view.findViewById(R.id.progressBar);
        progressTextView = (TextView)view.findViewById(R.id.slice_percent_complete);
        statusTextView = (TextView)view.findViewById(R.id.status_text_view);

        return view;
    }

    @Override
    protected void onPrinterSystemNotificationReceived(PrinterSystemNotification notification) {
        PrinterResponse.Process process = notification.getCurrentProcess();
        if( process == null ) {
            return;
        }
        progressBar.setProgress(Math.round(process.progress));
        progressTextView.setText(Math.round(process.progress)+"");

        if (process.getFilename() != null) {
            statusTextView.setText(getString(R.string.loading_print_file) + " " + process.getFilename().toUpperCase());
        }
    }

    protected void onPrinterStateNotificationReceived(PrinterStateNotification notification) {
        PrinterResponse.Process process = notification.getCurrentProcess();
        if (process == null) {
            return;
        }
        progressBar.setProgress(Math.round(process.progress));
        progressTextView.setText(Math.round(process.progress)+"");

        if (process.getFilename() != null) {
            statusTextView.setText(getString(R.string.loading_print_file) + " " + process.getFilename().toUpperCase());
        }
    }
}

0 个答案:

没有答案