[英]Android XML error while generating signed .apk file
I've not opened this particular project for about 3 months but when I tried to generate a signed .apk file, I get this one error only: 我大约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"
Here's my current code in that xml file: 这是该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>
Funny thing is, it worked multiple times previously and I did not make any changes at all. 有趣的是,它以前曾多次工作过,而我根本没有做任何更改。 I can also rebuild and clean build it without errors. 我也可以重建并清理它,而不会出错。 Oddly, my backup versions which are Identical, generate this ONE same error for my 6 different xml files here: 奇怪的是,我的备份版本相同,在这里为我的6个不同的xml文件生成了一个相同的错误:
Error:(5) Error: Suspicious namespace and prefix combination [NamespaceTypo]
It points to this line in each of the 6 files: 它指向6个文件中的每个文件的这一行:
xmlns:app="http://schemas.android.com/tools"
My guess is I'm not calling something in the MainActivity (but that would not explain why it has always worked -with fully functioning .apk) Any thoughts? 我的猜测是我没有在MainActivity中调用某些东西(但这不能解释为什么它一直有效-可以正常运行的.apk)有什么想法吗?
Thanks heaps! 谢谢堆! James 詹姆士
Remove this line 删除此行
android:layout_alignTop="@+id/linearLayout2"
From 从
<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" />
As i see no layout with id linearLayout2 in your file above. 我在上面的文件中没有看到ID为linearLayout2的布局。 Errors of such kind are not generated in the debug build but in the realease build. 此类错误不是在调试版本中生成的,而是在realease版本中生成的。
正如@Malik Ahhsan所说,只需删除android:layout_alignTop="@+id/linearLayout2"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.