gpt4 book ai didi

android - 如何处理 android.view.inflateexception 二进制 XML 文件行 #5

转载 作者:行者123 更新时间:2023-11-30 02:18:16 25 4
gpt4 key购买 nike

所以我正在开发,我遇到了一个膨胀异常,我不知道该怎么办。

日志猫:

03-09 16:33:12.018    8201-8201/org.aron.modiryar E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: org.aron.modiryar, PID: 8201
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.aron.modiryar/org.aron.modiryar.MainActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2237)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at `com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at org.aron.modiryar.fragment.MainMenu.onCreateView(MainMenu.java:41)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5241)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)

这是我的 android list :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.aron.modiryar"
android:versionCode="1"
android:versionName="1.0" android:uiOptions="splitActionBarWhenNarrow">

<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name"
android:theme="@style/AppBaseTheme" android:enabled="true" android:name=".system.Initialize"
android:uiOptions="splitActionBarWhenNarrow">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"
android:uiOptions="splitActionBarWhenNarrow" >
<meta-data android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

而我的无法充气的布局是这样的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mainmenulayer" android:layout_width="match_parent" android:layout_height="fill_parent" android:orientation="vertical" android:visibility="visible" style="@style/MainMenu">
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_title_height" android:orientation="horizontal" style="@style/RowMenu">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_title_collect" style="@style/RowMenuTitleText" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_inbox">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="@dimen/main_menu_row_count_margin_left">
<LinearLayout android:id="@+id/total_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TotalCount" android:orientation="horizontal"></LinearLayout>
<LinearLayout android:id="@+id/overdue_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/OverDueCount" android:visibility="invisible" android:orientation="horizontal"></LinearLayout>
</LinearLayout>
<org.aron.modiryar.view.TextView android:id="@+id/menu_inbox_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_inbox" style="@style/RowMenuText" />
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_inbox"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_title_height" android:orientation="horizontal" style="@style/RowMenu">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_title_focuse_on" style="@style/RowMenuTitleText" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_today">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="@dimen/main_menu_row_count_margin_left">
<LinearLayout android:id="@+id/total_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TotalCount"></LinearLayout>
<LinearLayout android:id="@+id/overdue_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/OverDueCount" android:visibility="invisible"></LinearLayout>
</LinearLayout>
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_today" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_today"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_next_action">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="@dimen/main_menu_row_count_margin_left">
<LinearLayout android:id="@+id/total_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TotalCount"></LinearLayout>
<LinearLayout android:id="@+id/overdue_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/OverDueCount" android:visibility="invisible"></LinearLayout>
</LinearLayout>
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_next_action" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_next"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_tomorrow">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="@dimen/main_menu_row_count_margin_left">
<LinearLayout android:id="@+id/total_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TotalCount"></LinearLayout>
<LinearLayout android:id="@+id/overdue_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/OverDueCount" android:visibility="invisible"></LinearLayout>
</LinearLayout>
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_tomorrow" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_tomorrow"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_calendar">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="@dimen/main_menu_row_count_margin_left">
<LinearLayout android:id="@+id/total_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TotalCount"></LinearLayout>
<LinearLayout android:id="@+id/overdue_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/OverDueCount" android:visibility="invisible"></LinearLayout>
</LinearLayout>
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_calendar" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_scheduled"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_someday">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="@dimen/main_menu_row_count_margin_left">
<LinearLayout android:id="@+id/total_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TotalCount"></LinearLayout>
<LinearLayout android:id="@+id/overdue_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/OverDueCount" android:visibility="invisible"></LinearLayout>
</LinearLayout>
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_sameday" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_someday"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_waitingfor">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginLeft="@dimen/main_menu_row_count_margin_left">
<LinearLayout android:id="@+id/total_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/TotalCount"></LinearLayout>
<LinearLayout android:id="@+id/overdue_count" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/OverDueCount" android:visibility="invisible"></LinearLayout>
</LinearLayout>
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_waitingfor" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_waiting"/>
</LinearLayout>

<LinearLayout android:layout_width="fill_parent" android:layout_height="@dimen/main_menu_divider_line_height" style="@style/MainMenuLine"/>
<LinearLayout android:layout_width="fill_parent" android:layout_height="@dimen/main_menu_divider_line_height" style="@style/MainMenuLineWhite"/>

<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_project">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_project" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_project"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_Goal">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_goal" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_goal"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_responsibility">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_responsibility" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_responsibility"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_vision">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_vision" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_inbox"/>
</LinearLayout>

<LinearLayout android:layout_width="fill_parent" android:layout_height="@dimen/main_menu_divider_line_height" style="@style/MainMenuLine"/>
<LinearLayout android:layout_width="fill_parent" android:layout_height="@dimen/main_menu_divider_line_height" style="@style/MainMenuLineWhite"/>

<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_reference">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_reference" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_inbox"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_trash">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_trash" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_trash"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_done">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_done" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_trash"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_routine">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_routine" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_inbox"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="@dimen/main_menu_row_height" android:orientation="horizontal" style="@style/RowMenu" android:id="@+id/menu_tags">
<org.aron.modiryar.view.TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/menu_tags" style="@style/RowMenuText"/>
<ImageView android:layout_width="@dimen/main_menu_row_icon_width" android:layout_height="@dimen/main_menu_row_icon_height" android:src="@drawable/home_tags"/>
</LinearLayout>
</LinearLayout>
</ScrollView>

正如您可能看到或可能看不到的那样,有一些 linearlayouts 具有相同的 ID,但我知道这不是我的问题。真正的问题是应用程序运行在早期的 android 版本上,但不能运行在更高的版本上。并且我已经尝试在 android list 中更改目标 sdk。

所以我缺少什么请帮忙。

public class TextView extends android.widget.TextView {
public TextView(Context context) {
super(context);
this.setTypeface(Config.getDefaultTypeFace(context));
}

public TextView(Context context, AttributeSet attrs) {
super(context, attrs);
this.setTypeface(Config.getDefaultTypeFace(context));
}

public TextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.setTypeface(Config.getDefaultTypeFace(context));
}
}

最佳答案

所以在大约 8 小时的工作后,我发现了我的问题所在,我发布了这个答案,以便它可以帮助其他人。

1- 正如您在堆栈跟踪中看到的那样,我的问题出在 MainMenu.java 中,它正在膨胀,所以我的问题在于布局膨胀。

2- XML 文件第 5 行在那个布局中。它可能看起来很无辜,但它有一种风格。

3- 在那种风格中,它的维度只在值中定义 - 大,这是我的问题。我必须在所有其他维度值中定义它才能工作。

注意:我的问题不在于 SDK 版本,而在于设备大小。希望这对别人有帮助。

关于android - 如何处理 android.view.inflateexception 二进制 XML 文件行 #5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28944296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com