Android Studio构建完成,但无法在真实设备上运行

时间:2018-05-05 09:27:08

标签: android

这是xml的主要活动

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    tools:context="com.example.liew.idelivery.MainActivity">


<LinearLayout
    android:orientation="vertical"
    android:layout_centerInParent="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:layout_gravity="center"
        android:src="@drawable/logo" />

    <TextView
        android:id="@+id/txtSlogan"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:gravity="center"
        android:text="@string/slogan"
        android:textAlignment="center"
        android:textColor="@android:color/white"
        android:textSize="18sp"
        android:textStyle="italic" />
</LinearLayout>

<LinearLayout
    android:orientation="horizontal"
    android:layout_alignParentBottom="true"
    android:weightSum="2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <info.hoang8f.widget.FButton
        android:id="@+id/btnSignUp"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:text="Sign Up"
        android:textColor="@android:color/white"
        app:buttonColor="@color/btnSignUp"
        app:cornerRadius="4dp"
        app:shadowColor="@android:color/black"
        app:shadowEnabled="true"
        app:shadowHeight="5dp" />

    <info.hoang8f.widget.FButton
        android:id="@+id/btnSignIn"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:text="Sign In"
        android:textColor="@android:color/white"
        app:buttonColor="@color/btnSignUp"
        app:cornerRadius="4dp"
        app:shadowColor="@android:color/black"
        app:shadowEnabled="true"
        app:shadowHeight="5dp" />


</LinearLayout>

这是我在logcat中发现的错误。

  E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.liew.idelivery, PID: 18266
    java.lang.RuntimeException: Unable to start activity 

ComponentInfo {com.example.liew.idelivery / com.example.liew.idelivery.MainActivit   y}:android.view.InflateException:二进制XML文件行#43:错误膨胀       class info.hoang8f.widget.FButton         在      android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2462)         在      android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2534)         在android.app.ActivityThread.access $ 900(ActivityThread.java:164)

2 个答案:

答案 0 :(得分:0)

我认为错误发生在RelativeLayout没有结束标记。如果问题仍然存在,请尝试附加MainActivity文件,我会检查它。

最后一条建议:尝试使用ConstraintLayout代替LinearLayoutRelativeLayout:)

答案 1 :(得分:0)

android.view.InflateException:二进制XML文件行#43:错误扩充类

只有xml文件中出现错误才会出现异常首先需要用标记关闭所有xml文件

</RelativeLayout>

其他可能性是您使用的自定义视图,请确保视图位于正确的路径上(包名称与路径一起存在)

info.hoang8f.widget.FButton