android.view.InflateException : 이진 XML 파일 행 # 12 : <unknown> 클래스 팽창 오류 com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 3. android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563) 4. android.view.LayoutInflater.rInflate(LayoutInflater.java:618) 5. android.view.LayoutInflater.rInflate(LayoutInflater.java:621) 6.

subj에 표시된 많은 종류의 오류가 발생합니다. 이러한 오류는 가끔 발생하는 것으로 보이며이를 재현 할 수 없습니다. 스택에서 다른 레이아웃 리소스에 대해 이러한 오류가 발생할 수 있음을 알 수 있습니다. XML 라인도 다양합니다.

왜이 오류가 발생했는지 설명 할 수 있습니까? 이 문제를 해결하기 위해 무엇을 할 수 있습니까?

스택

=============================================================

com.fsp.android.f generated the following exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fsp.android.f/com.life360.android.ui.tour.TourActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>

--------- Stack trace ---------
1. android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2649)
2. android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2674)
3. android.app.ActivityThread.access$2200(ActivityThread.java:131)
4. android.app.ActivityThread$H.handleMessage(ActivityThread.java:1975)
5. android.os.Handler.dispatchMessage(Handler.java:99)
6. android.os.Looper.loop(Looper.java:123)
7. android.app.ActivityThread.main(ActivityThread.java:4702)
8. java.lang.reflect.Method.invokeNative(Native Method)
9. java.lang.reflect.Method.invoke(Method.java:521)
10. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
11. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
12. dalvik.system.NativeStart.main(Native Method)
-------------------------------

----------- Cause -----------
android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>

1. android.view.LayoutInflater.createView(LayoutInflater.java:513)
2. com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
3. android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
4. android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
5. android.view.LayoutInflater.rInflate(LayoutInflater.java:621)
6. android.view.LayoutInflater.inflate(LayoutInflater.java:382)
7. android.view.LayoutInflater.inflate(LayoutInflater.java:320)
8. android.view.LayoutInflater.inflate(LayoutInflater.java:276)
9. com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:208)
10. android.app.Activity.setContentView(Activity.java:1629)
11. com.solvek.sample.ui.BaseActivity.onCreate(BaseActivity.java:23)
12. com.solvek.sample.ui.tour.TourActivity.onCreate(TourActivity.java:161)
13. android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
14. android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2587)
15. android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2674)
16. android.app.ActivityThread.access$2200(ActivityThread.java:131)
17. android.app.ActivityThread$H.handleMessage(ActivityThread.java:1975)
18. android.os.Handler.dispatchMessage(Handler.java:99)
19. android.os.Looper.loop(Looper.java:123)
20. android.app.ActivityThread.main(ActivityThread.java:4702)
21. java.lang.reflect.Method.invokeNative(Native Method)
22. java.lang.reflect.Method.invoke(Method.java:521)
23. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
24. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
25. dalvik.system.NativeStart.main(Native Method)
-----------------------------

-------- Environment --------
Time =2010-12-20 08:27:35 AM
Device =tmobile/htc_espresso/espresso/espresso:2.1-update1/ERE27/216830:user/release-keys
Make =HTC
Model =T-Mobile myTouch 3G Slide
Product =htc_espresso
App =com.fsp.android.f, version 2.0.9 (build 1232)

다음은 XML의 결과이지만 다른 XML에서 이러한 오류가 발생합니다.

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <ViewFlipper android:layout_gravity="fill" android:id="@+id/flipper" android:layout_height="fill_parent" android:layout_width="fill_parent">
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_1"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_2"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_3"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_4"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_5"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_6"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_7"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_8"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_9"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_10"/>
        <ImageView android:scaleType="fitXY" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/tour_11"/>
    </ViewFlipper>

    <LinearLayout android:id="@+id/exit_bar" android:layout_gravity="top" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/blue_bar" android:visibility="invisible">
        <Button android:background="@drawable/orange_btn" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center" android:textStyle="bold" android:textColor="#000000" android:shadowColor="#ffffff" android:shadowRadius="1.6" android:shadowDx="1.5" android:shadowDy="1.3" android:id="@+id/exit_tour_btn" android:text="Exit" android:layout_marginLeft="20dip"/>
        <TextView android:layout_height="wrap_content" android:textColor="#ffffff" android:layout_gravity="center" android:layout_width="110dip" android:layout_marginLeft="20dip" android:textSize="16dip" android:textStyle="bold" android:text="Life360 Tour"/>

    </LinearLayout>

    <Button style="@style/BlueBtn" android:text="Continue" android:layout_marginTop="40dip" android:id="@+id/continue_btn" android:visibility="gone" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center" />

    <FrameLayout android:id="@+id/bottom_bar" android:layout_gravity="bottom" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/blue_bar" android:visibility="invisible">
        <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/left" android:layout_gravity="left|center" android:background="@drawable/tour_left" android:layout_marginLeft="10dip"/>
        <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/right" android:layout_gravity="right|center" android:background="@drawable/tour_right" android:layout_marginRight="10dip"/>               
    </FrameLayout>
</merge>


답변

팽창 예외는 실제로는 문제가 아니지만 실제로 레이아웃의 다른 더 깊은 문제에서 비롯된 다음 InflateException에 래핑됩니다. 일반적인 문제는 드로어 블 리소스를로드하는 이미지 뷰를 부 풀릴 때 메모리 부족 예외입니다. 이 리소스 중 하나의 픽셀 해상도가 높으면 많은 메모리가 필요하여 팽창 예외가 발생합니다.

따라서 기본적으로 드로어 블 이미지의 픽셀 해상도가 레이아웃에 필요한 최소값인지 확인하십시오.


답변

ViewFlipper레이아웃 팽창 중에 모든 이미지를 메모리에로드합니다. 내 이미지가 큰 때문에 내가 교체, 많은 메모리를 필요 ViewFlipperImageSwitcher하는 등의 애니메이션 이미지를 변경할 수 ViewFlipper있지만,이 번에 하나의 이미지를로드합니다.


답변

사용하는 VectorDrawable지원 라이브러리를 사용하는 app:srcCompat대신 사용을 잊어 버린 경우에도 발생할 수 있습니다android:src

정확한 오류는 다음과 같습니다.
이진 XML 파일 줄 #XX : 클래스 ImageView 팽창 오류

그 링크를 참조하십시오


답변

하나의 생성자로만 사용자 정의보기를 만들 때 동일한 오류가 발생했습니다. 사용자 정의보기에 대한 모든 생성자를 정의하십시오.

   public CustomWebView(Context context) {
        super(context);
        init();
    }

    public CustomWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public CustomWebView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

답변

나는 질문에 이미 답변되었지만 여전히 누군가가 이런 종류의 문제에 부딪 칠 수 있다고 생각하여 게시하고 있습니다.

내 문제는 res / layout / 폴더의 레이아웃과 res / values ​​/ dimens의 @dimens 값을 참조하는 전화로 응용 프로그램을로드하는 것입니다. 액세스하려는 font_22이며 res / values-xlarge에 정의되어 있습니다. / 흐리게합니다.

실제로 기존 프로젝트의 UI를 업데이트하고 있습니다.

레이아웃 폴더에 xml을 작성하는 동안 힌트를 위해 Ctrl + Space를 사용하는 IDE Eclipse를 사용하고 있기 때문에이 문제가 발생했습니다. 내가 작성하는 폴더에 관계없이 값의 모든 값과 value-xlarge 폴더를 표시합니다.

또한 두 파일의 값이 다른 화면에 매핑되도록 동일해야한다는 것을 알고 있습니다.

이것이 누군가가 이런 종류의 바보 같은 문제에 부딪 칠 수 있기를 바랍니다.


답변

나는 같은 버그가 발생했으며 근본 이유는 다음과 같습니다.

응용 프로그램 컨텍스트를 사용하여 뷰를 부풀립니다.

Activity Context로 팽창하면 버그가 수정되었습니다.


답변

내 사진 크기는 14Kb에 불과하지만 문제는 디자이너가 1011px x 1819px (해상도가 너무 높아서 InflateException을 유발 함)를 제공한다는 것입니다.