2017-09-03 81 views
0

我没有打开这个特定的项目约3个月,但是当我试图生成一个签名的.apk文件,我得到只有这一个错误:Android的XML错误而产生签署.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)有什么想法?

谢谢堆! 詹姆斯

+0

的这里的问题是,你没有带身份证“linearLayout2”的布局,但您尝试访问它。尝试从您的textview中删除android:layout_alignTop =“@ + id/linearLayout2” –

回答

0

删除此行

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没有布局在上述文件。在调试版本中不会生成这种类型的错误,但在释放版本中。

+0

感谢堆队友!有效! – solodeveloper

+0

很高兴知道。 Plz将答案标记为正确,以便对其他人也有所帮助。也plz upvote答案。谢谢 –

0

正如@Malik Ahhsan说,刚取出android:layout_alignTop="@+id/linearLayout2"

+0

完美的家伙!它实际上工作。简单地删除它。 .apk一代中,我不知道它为什么被添加到第一位。 – solodeveloper

+0

@solodeveloper祝你好运我的朋友:) – Shareefoo

相关问题