2017-09-03 80 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

相關問題