繁体   English   中英

生成签名的.apk文件时出现Android XML错误

[英]Android XML error while generating signed .apk file

我大约3个月没有打开这个特定项目,但是当我尝试生成一个签名的.apk文件时, 我仅收到此错误:

C:\app\src\main\res\layout\fragment_newanswers.xml:57: Error: The id "linearLayout2" is not defined anywhere. [UnknownId]
                android:layout_alignTop="@+id/linearLayout2"

这是该xml文件中的当前代码:

<TextView
        android:text="OptionView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/txtOptionTitle"
        android:textSize="24sp"
        android:textAlignment="center" />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtOptionTitle"
        android:layout_alignParentStart="false"
        android:layout_alignParentBottom="false">
<!--
        <TextView
            android:text="QuestionView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/txtQuestionTitle"
            android:textAlignment="center"
            android:textSize="18sp" />
-->
        <com.rokonoid.widget.ExpandableTextView
            android:id="@+id/txtQuestionTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="18sp" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <com.bozapro.circularsliderrange.CircularSliderRange
                android:id="@+id/cirAns"
                android:layout_width="wrap_content"
                android:layout_height="343dp"
                circular:start_angle="270"
                circular:end_angle="300"
                circular:start_thumb_size="0dp"
                android:paddingLeft="75dp"
                android:paddingRight="75dp" />

            <TextView
                android:text="5%"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/linearLayout2"
                android:layout_centerHorizontal="true"
                android:id="@+id/txtPercent"
                android:textAlignment="center"
                android:textSize="36sp"
                android:layout_marginTop="150dp" />
        </RelativeLayout>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button
                android:text="Back"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/btnQnsBack"
                android:layout_weight="1" />

            <Button
                android:text="Next"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/btnQnsNext"
                android:layout_weight="1" />
        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

有趣的是,它以前曾多次工作过,而我根本没有做任何更改。 我也可以重建并清理它,而不会出错。 奇怪的是,我的备份版本相同,在这里为我的6个不同的xml文件生成了一个相同的错误:

Error:(5) Error: Suspicious namespace and prefix combination [NamespaceTypo]

它指向6个文件中的每个文件的这一行:

xmlns:app="http://schemas.android.com/tools"

我的猜测是我没有在MainActivity中调用某些东西(但这不能解释为什么它一直有效-可以正常运行的.apk)有什么想法吗?

谢谢堆! 詹姆士

删除此行

android:layout_alignTop="@+id/linearLayout2"

<TextView
            android:text="5%"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/linearLayout2"
            android:layout_centerHorizontal="true"
            android:id="@+id/txtPercent"
            android:textAlignment="center"
            android:textSize="36sp"
            android:layout_marginTop="150dp" />

我在上面的文件中没有看到ID为linearLayout2的布局。 此类错误不是在调试版本中生成的,而是在realease版本中生成的。

正如@Malik Ahhsan所说,只需删除android:layout_alignTop="@+id/linearLayout2"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM