gpt4 book ai didi

java - 出现致命异常无法理解原因

转载 作者:行者123 更新时间:2023-12-01 21:50:22 25 4
gpt4 key购买 nike

我一直在处理一个项目,我成功地更改了布局文件并运行该项目。它得到构建而没有显示任何错误。

这是 LogCat 跟踪:

02-09 15:50:42.923    2720-2720/com.blues.app D/AndroidRuntime﹕ Shutting down VM
02-09 15:50:42.924 2720-2720/com.blues.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.blues.app, PID: 2720
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.blues.app/com.blues.app.Login_Activity}: android.view.InflateException: Binary XML file line #36: Binary XML file line #36: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #36: Binary XML file line #36: Error inflating class <unknown>
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
at android.app.Activity.setContentView(Activity.java:2166)
at com.blues.app.Login_Activity.onCreate(Login_Activity.java:20)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class <unknown>
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:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
            at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
            at android.app.Activity.setContentView(Activity.java:2166)
            at com.blues.app.Login_Activity.onCreate(Login_Activity.java:20)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
            at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
            at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
            at android.app.Activity.setContentView(Activity.java:2166)
            at com.blues.app.Login_Activity.onCreate(Login_Activity.java:20)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:666)
at android.widget.TextView.<init>(TextView.java:1055)
at android.widget.TextView.<init>(TextView.java:671)
at android.widget.TextView.<init>(TextView.java:667)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at android.view.LayoutInflater.createView(LayoutInflater.java:619)
            at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
            at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
            at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
            at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)
            at android.app.Activity.setContentView(Activity.java:2166)
            at com.blues.app.Login_Activity.onCreate(Login_Activity.java:20)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-09 15:50:50.215 2720-2720/com.blues.app I/Process﹕ Sending signal. PID: 2720 SIG: 9

Activity 类别

package com.blues.app;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.widget.EditText;
import android.widget.ProgressBar;

/**
* Created by iSandeep on 2/9/2016.
*/
public class Login_Activity extends Activity {

EditText Username,Password;
ProgressBar login_Progress;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
}

Xml布局activity_login

<RelativeLayout 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="@drawable/my_shape"
android:padding="16dp"
tools:context="com.blues.app.Login_Activity">

<FrameLayout
android:id="@+id/Header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:padding="16dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:textColor="#000000"
android:text="SkyEdu"
android:textSize="34dp"/>

</FrameLayout>

<ScrollView
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/Header"
android:layout_marginTop="@dimen/abc_action_bar_default_height_material">

<LinearLayout
android:id="@+id/llMyLinearLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:id="@+id/tvLbl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="?android:attr/textAppearanceMedium"
android:text="Username"/>

<EditText
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme"
android:inputType="text"
android:padding="10dp"
android:hint="Your Username"/>

<TextView
android:id="@+id/tvLblPass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:layout_marginTop="10dp"
android:textSize="?android:attr/textAppearanceMedium"
android:text="Password"/>

<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeActionId="@+id/login"
android:theme="@style/AppTheme"
android:inputType="textPassword"
android:padding="10dp"
android:hint="Your Password"/>

<!-- Login progress -->
<ProgressBar
android:id="@+id/login_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="20dp"
android:visibility="gone" />

<Button
android:id="@+id/email_sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#2196f3"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:padding="20dp"
android:textSize="20sp"
style="?android:attr/borderlessButtonStyle"
android:text="SIGN IN"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#000000"
android:layout_marginTop="20dp"
android:text="NextSky Technologies Pvt. Ltd."/>
</LinearLayout>

</ScrollView>

<!--<ScrollView android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:theme="@android:style/Theme.Translucent">

<LinearLayout android:id="@+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
android:layout_marginLeft="@dimen/pageMargin"
android:layout_marginRight="@dimen/pageMargin"
android:paddingBottom="@dimen/pageMargin"
android:padding="@dimen/pageMargin"
android:orientation="vertical"
android:gravity="center_horizontal|center_vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:visibility="gone"
android:text="@string/Chk"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:background="@drawable/main_img"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/minerMargin"
android:gravity="center_horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/whiteBg"
android:text="@string/LoginHeader"
android:textStyle="bold"
android:textSize="@dimen/textSize"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/whiteBg"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:text="@string/LoginHeader1"
android:textSize="@dimen/textSize"/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">

<AutoCompleteTextView android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:singleLine="true"
android:textCursorDrawable="@drawable/cursor"
android:background="@drawable/abc_popup_background_mtrl_mult"
android:hint="@string/Username"
android:padding="@dimen/LoginTextBoxPadding"
android:textSize="@dimen/textSize"
android:textColor="#000000"
android:text=""
android:layout_marginLeft="@dimen/minerMargin"
android:layout_marginRight="@dimen/minerMargin" />

<EditText android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:imeActionId="@+id/login"
android:textCursorDrawable="@drawable/cursor"
android:imeActionLabel="@string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:text=""
android:maxLines="1"
android:textColor="#000000"
android:singleLine="true"
android:background="@drawable/abc_popup_background_mtrl_mult"
android:padding="@dimen/LoginTextBoxPadding"
android:textSize="@dimen/textSize"
android:layout_marginLeft="@dimen/minerMargin"
android:layout_marginRight="@dimen/minerMargin"/>

<Button android:id="@+id/email_sign_in_button"
android:text="@string/btnLogin"
android:textColor="@color/BtnTextColor"
android:textAllCaps="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/login_button"
android:shadowColor="#A8A8A8"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="5"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginTop="@dimen/minerMargin"
android:layout_marginRight="@dimen/minerMargin"
android:layout_marginEnd="@dimen/minerMargin"
android:layout_gravity="end"/>
</LinearLayout>
</LinearLayout>
</ScrollView>-->
</RelativeLayout>

到目前为止,我已经尝试过清理和构建,为同一任务创建新的 Activity 。但它给出了同样的异常(exception)。

如果您需要任何其他信息,请在评论中提及。谢谢。

最佳答案

试试这个:

替换

android:layout_marginTop="@dimen/abc_action_bar_default_height_material"

android:layout_marginTop="10dp"

欲了解更多详情,请访问 this链接

关于java - 出现致命异常无法理解原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35289715/

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