Android XML error while generating signed .apk file - android

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:
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:
<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:
Error:(5) Error: Suspicious namespace and prefix combination [NamespaceTypo]
It points to this line in each of the 6 files:
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?
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. Errors of such kind are not generated in the debug build but in the realease build.

As #Malik Ahhsan said, just remove the android:layout_alignTop="#+id/linearLayout2"

Related

"this project contains resource errors, So aapt did not succeed, which can cause rendering failures, fix resources problems first." In Android studio

Blockquote
I am new in Android studio, I created a program and got resource error, please help me to fix this problem.
it shows error that "This project contains resource errors, so aapt did not succeed, which can cause rendering failure. fix resource problem first.
please help me in solving this issue.
code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:gravity="center_horizontal"
tools:context=".MainActivity">
<!-- Display whether Bluetooth is avilable or not-->
<TextView
android:id="#+id/statusBluetoothTv"
android:layout_width="match_parent"
android:layout_height="14dp"
android:minWidth=""
android:text=" "
android:textAlignment="center"
android:textColor="#000"
android:textSize="20sp" />
<!--Bluetooth icon (on/off)-->
<ImageView
android:id="#+id/bluetoothIv"
android:layout_width="100dp"
android:layout_height="100dp"
<Button
android:id="#+id/onBtn"
android:minWidth="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn On"
style="#style/Base.Widget.AppCompat.Button.Colored" />
<!--off btn-->
<Button
android:id="#+id/offBtn"
android:minWidth="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn Off"
style="#style/Base.Widget.AppCompat.Button.Colored" />
<!--Discoverable Button-->
<Button
android:id="#+id/DiscoverableBtn"
android:minWidth="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Discover devices"
style="#style/Base.Widget.AppCompat.Button.Colored" />
<!--Get list of Paired devices button-->
<Button
android:id="#+id/pairedBtn"
android:minWidth="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get paired Devices"
style="#style/Base.Widget.AppCompat.Button.Colored" />
<!--show paired devices here-->
<TextView
android:id="#+id/pairedTv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minWidth="200dp"
android:text=""
android:textColor="#000" />

EditText disappears on Android Marshmallow 6.0 devices

This is how my xml layout file in IDE looks like:
It looks like that on every device BUT Marshmallow ones, which ended up looking like this:
As you can see, the password EditText and Remember CheckBox disappeared without a trace, yet I still can declare them in the class file normally.
This is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_log_in"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="my.app.LogInActivity">
<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"
android:id="#+id/linearLayout5"
android:orientation="horizontal" />
<!-- :nextFocusUp and :nextFocusLeft have been set to the id of this component
to prevent the dummy from receiving focus again -->
<AutoCompleteTextView android:id="#+id/autotext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:nextFocusUp="#id/autotext"
android:visibility="invisible"
android:nextFocusLeft="#id/autotext"
android:textSize="15sp" />
<TextView
android:id="#+id/txtname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/txt_customer"
android:layout_alignBottom="#+id/txt_customer"
android:text="Name"
android:textSize="14sp" />
<EditText
android:id="#+id/txt_customer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="#+id/autotext"
android:layout_toEndOf="#+id/bt_exit"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textPersonName"
android:maxLength="100"
android:textSize="15sp" />
<EditText
android:id="#+id/txt_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView2"
android:layout_alignBottom="#+id/textView2"
android:layout_alignParentEnd="true"
android:layout_alignStart="#+id/txt_customer"
android:ems="10"
android:imeOptions="flagNoExtractUi"
android:inputType="textPassword"
android:maxLength="100"
android:textSize="15sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtname"
android:layout_alignStart="#+id/txtname"
android:layout_below="#+id/txt_customer"
android:layout_marginTop="25dp"
android:text="Pasword"
android:textSize="14sp" />
<Button
android:id="#+id/bt_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:text="LogIn"
android:textColor="#000000" />
<Button
android:id="#+id/bt_exit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="#+id/linearLayout5"
android:text="Quit"
android:textColor="#000000" />
<CheckBox
android:id="#+id/check_remember"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/txt_password"
android:layout_below="#+id/txt_password"
android:text="Remember" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout5"
android:layout_toEndOf="#+id/linearLayout5"
android:text="Log In" />
The Name EditText and Password EditText are the same yet only the Password one disappears on Marshmallow 6.0 devices. I have already tried to change theme, Build Target, position but it's still the same. What had go wrong?
EDIT #1:This question mentioned "messy code" and it was solved by "cleaning up" the code. I am using RelativeLayout as parent like him, but changing to LinearLayout isn't viable.
EDIT #2: I tried to preset a value just to login, and it worked normally like I just typed it in manually. Inside layouts file are the same: Only one EditText appears, the rest (EditText, CheckBox, RadioButtons) disappear. What is going on?? Example:
On Marshmallow:
Solved the disappearing bug. From this SO answer which leads me to this Google issue. I have to delete android:layout_alignBaseline attribute and they will render fine.

Android Layout Issue Using axml - In Xamarin

Can anyone see a problem with the code below?
The error is that the id Title is not being recognised as a valid id when I try to use it for alignment even though it is created above the reference in the hierarchy.
The warning sign says: The referenced resource does not exist.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="150dp"
android:background="#android:color/white"
android:orientation="horizontal">
<TextView
android:id="#+id/Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:lineSpacingExtra="3dp"
android:paddingLeft="10dp"
android:paddingTop="5dp"
android:textColor="#ffffff"
android:textStyle="bold"
android:background="#android:color/holo_green_light"
android:typeface="sans"
android:text="AAAAA"
android:layout_centerVertical="true" />
<TextView
android:id="#+id/Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="5dp"
android:textColor="#android:color/black"
android:textSize="11sp"
android:text="aaaaaaa"
android:layout_alignTop="#id/Title"
/>
</RelativeLayout>
Didn't see anything wrong with your axml file and it worked fine for me in Xamarin. No errors. Have you tried a clean build? Sometimes errors in other axml files cause errors in correct files. Try removing both textviews and recompiling. Maybe that will show any other errors.

All texts in the app are gone after a while

This is probably the weirdest thing it ever happened to me. I inherit this code from another developer and I can't figure out which is the problem.
The app uses the sherlocknabvar and it also has a screen with a mapfragment where you can move a pin around and once the map is settled it calls several APIs to get some info about your position. The rest of the activities are pretty normal, nothing fancy about them. The map activity is quite complex though.
This is the error I have... weirdest thing is that it only happens sometimes, so it's not easy to reproduce it but I still can see it happen from time to time.
After playing with the map for a while (moving the pin, zooming in and out and so on) if I go back to the main activity (by clicking a home button on the navbar or by clicking the back button) all the texts in my app are gone in all the activities. I can see all the different layouts with images and colours but all the texts are completely gone. The only way to have them back is by restarting the app.
Looking at the Android Device Monitor (in case was some memory leak) everything looked pretty stable (28016K/33287K as max) and even worst, I can reproduce that error in an old Sony Xperia but also in a new brand S5.
EDIT
I found out that the texts where not missing, the color was changing to transparent for some reason that I still don't get. I disabled the hardware acceleration and it works but I'm still wondering what the problem could be and why that changed fixed it.
This is one of the layouts I'm having problems with, all the TextViews just change to transparent without any reason. It happens to the TextViews that have an 'static' text and also to the ones that I change the text dynamically.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="#drawable/new_bg_background_app"
>
<ScrollView
android:layout_alignParentTop="true"
android:layout_above="#+id/anc_button"
android:fadeScrollbars="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/anc_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="25dp"
android:gravity="center"
android:text="#string/lb_confirmed"
android:textColor="#color/orange"
android:textAppearance="#style/Font50PX"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ic_confirmed"
android:layout_marginTop="15dp"
android:src="#drawable/new_ic_active"
android:layout_below="#+id/anc_title"
android:layout_centerHorizontal="true" />
<TextView
android:id="#+id/lb_pick_up"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center"
android:layout_below="#+id/ic_confirmed"
android:text="#string/lb_your_pick_up"
android:textAppearance="#style/Font28PX"
android:textColor="#color/text_gray" />
<TextView
android:id="#+id/txt_passengers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="#+id/lb_pick_up"
android:text="5 Passengers"
android:textAppearance="#style/Font50PX"
android:textColor="#color/white"/>
<TextView
android:id="#+id/lb_from"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="6dp"
android:layout_below="#+id/txt_passengers"
android:text="#string/lb_from"
android:layout_marginTop="15dp"
android:textAppearance="#style/Font28PX"
android:gravity="center"
android:textColor="#color/text_gray" />
<TextView
android:id="#+id/txt_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="60"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:layout_below="#+id/lb_from"
android:textAppearance="#style/Font50PX"
android:textColor="#color/white"
/>
<TextView
android:id="#+id/txt_post_code"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="60"
android:gravity="center"
android:layout_below="#+id/txt_address"
android:textAppearance="#style/Font45PX"
android:textColor="#color/text_gray"
/>
<TextView
android:id="#+id/lb_at"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_post_code"
android:text="#string/lb_at"
android:layout_marginTop="15dp"
android:textAppearance="#style/Font28PX"
android:gravity="center"
android:textColor="#color/text_gray" />
<TextView
android:id="#+id/txt_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_below="#+id/lb_at"
android:textAppearance="#style/Font50PX"
android:text="9:00 AM Today"
android:textColor="#color/white"
/>
<TextView
android:id="#+id/txt_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_time"
android:layout_marginTop="20dp"
android:gravity="center"
android:text="#string/lb_mini"
android:textAppearance="#style/Font26PX"
android:textColor="#color/text_gray"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/txt_note"
android:layout_marginTop="10dp"
android:gravity="center"
>
<TextView
android:id="#+id/lb_reference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lb_reference"
android:layout_marginTop="15dp"
android:textAppearance="#style/Font32PX"
android:textColor="#color/white"
/>
<TextView
android:id="#+id/txt_reference"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/lb_reference"
android:layout_marginLeft="4dp"
android:layout_marginTop="17dp"
android:textAppearance="#style/Font28PX"
android:textColor="#color/white"
/>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/anc_button"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:text="#string/lb_done"
android:background="#drawable/new_btn_orange"
android:layout_margin="5dp"
android:onClick="onDone"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
</RelativeLayout>
This issue was fixed after disabling the hardware acceleration in the manifest just for the activity I was having the problem with
android:hardwareAccelerated="false"

Android XML error: no resource identifier found for attribute 'xmlns' in package 'android'

I know there are a hundred questions here just like mine, but none of them seem to suit my specific problem, so I am asking a new question. Just in case this is a repeat, I'm sorry.
So, I am building an app, and the layout is causing me a few problems.
This is my XML code : (it's not yet complete)
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/toosl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
android:xmlns="http://schemas.android.com/apk/res/android" >
<TextView
android:id="#+id/showNunmber"
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="number"
android:textSize="30sp"/>
<TextView
android:id="#+id/showAnswer"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="answer"
android:layout_marginTop="35dp"
android:layout_gravity="center"
android:textSize="25sp"/>
</LinearLayout>
The error that I'm getting is in the first line of the code
where it says "error: no resource identifier found for attribute 'xmlns' in package 'android'
I've gone over and over the code, I've tried to refresh/rebuild the project, I tried deleting that particular line, etc.. and nothing seems to solve it.
So, if anyone has some ideas?
Thanks!
Remove
android:xmlns="http://schemas.android.com/apk/res/android"
from your layout,i.e. use your layout as
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/toosl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/showNunmber"
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="number"
android:textSize="30sp"/>
<TextView
android:id="#+id/showAnswer"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="answer"
android:layout_marginTop="35dp"
android:layout_gravity="center"
android:textSize="25sp"/>
</LinearLayout>
Replace it with this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
>
<TextView
android:id="#+id/showNunmber"
android:layout_width="wrap_content"
android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="number"
android:textSize="30sp"/>
<TextView
android:id="#+id/showAnswer"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="answer"
android:layout_marginTop="35dp"
android:layout_gravity="center"
android:textSize="25sp"/>
</LinearLayout>
I found my mistake, it's in the last attribute of my first LinearLayout tag.
I should not have included that line at the bottom.
I removed that line and now its working.
Thank you!
if none of the above worked make sure you add this:
compile 'com.android.support:percent:23.1.1'
to your build.gradle

Categories

Resources