I have a nice FrameLayout as main container and some other views inside it's hierarchy.
But the preview shows a simple ActionBarOverlayLayout.
What is that? Why is it here?
I have Android Studio 3.0.0
I have tried:
Restart Android Studio. Refresh the preview by resizing. Changed the preview device, changed the SDK of the preview, changed the blueprint\design options, pressed "force refresh layout" Button.
XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp">
<com.makeramen.roundedimageview.RoundedImageView
android:layout_width="match_parent"
android:layout_height="#dimen/walk_list_item_height"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="centerCrop"
app:layout_heightPercent="25%"
app:layout_marginLeftPercent="0%"
app:layout_marginTopPercent="0%"
app:layout_widthPercent="100%"
app:riv_corner_radius="#dimen/corner_radius"
android:id="#+id/walk_iv" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/gradient"
android:orientation="vertical"
android:paddingBottom="16dp"
android:paddingTop="16dp">
<TextView
android:id="#+id/walk_name_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_vertical"
android:padding="16dp"
android:text="New Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#fff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_duration_icon" />
<TextView
android:id="#+id/duration_tv"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:gravity="center|left"
android:text="TextView"
android:textColor="#fff" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_marker"
android:layout_marginLeft="16dp" />
<TextView
android:id="#+id/stops_tv"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView"
android:textColor="#fff" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
That is because there is a broken build in your earlier build. It is coming from the intermediate files which is because the files are not proper in your xml files. There might be a broken link or a - in the drawables names.
Until you resolve this you cannot proceed to see the layout of your app in the layout-editor.
Moreover Android Studio will not show you any error in the error log or any other terminal.
Start from the styles/themes of the app, it might contain something which is missing from the gradle or resources of the project. Due to the support library still in the project it partially showcases it as missing control of XML files, but it will not let you load the xml editor visually for the project.
You have see that by yourself, start first from drawables and then move to values folder, if not check your gradle and then come back to Java files for the error.
Had to raise
buildToolsVersion to 26.0.0
previous was bugged (25.0.2)
I faced the same problem and, In my case, it was simpler than that. I just received a warning message recommending to remove the explict reference to the BuildToolsVerison from build.gradle file so I just did it, then saved all file, Menu >> Run >> Make a project and it worked fine.
Related
I have a project in Android and everything is okay then when i open the project yesterday this kept giving me this error
Rendering Problems
NOTE: One or more layouts are missing the layout_width or layout_height attributes. These are required in most layouts.
"invisible" in attribute "visibility" is not a valid integer (109 similar errors not shown)
Tip: Try to refresh the layout.
even when i start a new project and i go to the layout it kept giving me the error.
<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:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:background="#color/backgroundDark"
tools:context="coalesce.collabup.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/Logo"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="CollabUp"
android:textSize="70sp"
android:lineSpacingExtra="8sp"
android:typeface="normal"
android:textAlignment="center"
android:textStyle="normal|bold" />
<TextView
android:id="#+id/motto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="Collaboration at its finest"
android:textStyle="normal|bold"
android:textAlignment="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="50dp" />
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true"
android:textSize="18sp"
android:padding="10dp"
android:layout_marginBottom="10dp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:imeActionId="#+id/login"
android:imeActionLabel="Sign In"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<CheckBox
android:text="keep me log in?"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/checkBox2"
android:layout_marginTop="10dp" />
<Button
android:id="#+id/email_sign_in_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:text="Sign In"
android:textStyle="bold"
android:layout_marginLeft="250dp"
android:layout_marginBottom="10dp"
/>
</RelativeLayout>
<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/registertxt"
android:text="New to CollabUp? Create an Account now!"
android:textStyle="normal|bold"
android:textAlignment="center"
android:textSize="14sp"
android:onClick="gotoRegister"
android:layout_marginBottom="20dp" />
<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/forgettxt"
android:text="Forgot your password?"
android:textStyle="normal|bold"
android:textAlignment="center"
android:onClick="gotoSendForget"
android:textSize="14sp" />
<TextView
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="#+id/creditstxt"
android:text="Coalesce 2016 - All rights Reserved - CollabUp"
android:textStyle="normal|bold"
android:textColor="#android:color/white"
android:textAlignment="center"
android:textSize="14sp"
android:layout_marginTop="20dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
The issue is resolved by these changes:
Close Android Studio
Go to C:\Users\UserName.android and rename the build-cache folder to buildcache.bak
Go to C:\Users\UserName.AndroidStudio3.2\system and rename these folders
(1) caches to caches.bak
(2) compiler to compiler.bak
(3) compile-server to compile-server.bak
(4) conversion to conversion.bak
(5) external_build_system to external_build_system.bak
(6) frameworks to frameworks.bak
(7) gradle to gradle.bak
(8) resource_folder_cache to resource_folder_cache.bak
Open the Android Studio and open your project again.
This issues is caused in newer versions of android studio 3.2 you can fix the error by deleting the cache files.
step 1 : close android studio.
step 2: Go to .AndroidStudio3.2->system->caches.
step 3: Delete all files.
step 4: open Android studio
Your template is corrupted. Just go file and then setting. On the top search box, search templates and find file and code template. Choose that then choose other tab at the right hand side. click android and click layoutResourcesFile.xml.
copy and paste the below code on it and make sure you click live templates.
<?xml version="1.0" encoding="utf-8"?>
<${ROOT_TAG} xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="${LAYOUT_WIDTH}"
android:layout_height="${LAYOUT_HEIGHT}">
</${ROOT_TAG}>
I also got this error. I was helped by the following:
Remove the Android Studio files
To delete any remains of Android Studio setting files, in File Explorer, go to your user folder (%USERPROFILE%), and delete .android, .AndroidStudio and any analogous directories with versions on the end, i.e. .AndroidStudio1.2, as well as .gradle and .m2 if they exist.
The source is here
But I have not deleted these folders. I removed the dots in the folder name. After that, I launched Android Studio. She suggested that I export the settings from the old folders (in which I removed the dots in the title). I refused and re-tuned the studio. After that I opened the project and everything works.
Sorry for my english. I hope you understand my answer :)
The only thing that worked for me.
1. Download Android studio from the official website https://developer.android.com/studio/#downloads.
2. Install
You can even import settings from the previos install.
Now the render is fixed
I used the simple feature of Clean Project (Build -> Clean Project) and it somehow worked for me!
Everytime I put a #drawable item it appears underlined in red. It worked before but I pressed one of the options in the light bulb that appears next to the line and then all drawables became errors. I can't find the problem... I'm working with Android Studio. I tried to rebuild, clean, reimport... and nothing solves the problem.
My code:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="*" android:stretchColumns="*" android:background="#ffffff">
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/back"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:background="#null"
android:src="#drawable/backstate" /> /////////////////ERROR in "#drawable/backstate" (Underlined in red)
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/blanc"
android:layout_marginTop="50dp"
android:layout_marginLeft="20dp"
android:background="#null"
android:src="#drawable/blancstate"/> /////////////////SAME ERROR
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/groc"
android:layout_marginTop="50dp"
android:layout_marginRight="20dp"
android:background="#null"
android:src="#drawable/grocstate"/> /////////////////SAME ERROR
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/taronja"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:background="#null"
android:src="#drawable/taronjastate"/> /////////////////SAME ERROR
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:id="#+id/vermell"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:background="#null"
android:src="#drawable/vermellstate"/> /////////////////SAME ERROR
</TableRow>
</TableLayout>
All xml states are correct, layouts are well formed, i didn't change anything from the code, and by clicking that option that I didn't remember, all drawables started to give me errors.
ERROR DESCRIPTION: Top level element is not completed. Valid XML document must have a root tag.
Anyway the document is well formed... And it says the same error each time I write "#drawable/..."
EDIT: I found the origin of the problem. android namespace is the problem, if I change it for tools namespace it works. tools:src="#drawable/vermellstate" for example.
Can anyone help me please?
Try this:
Select item that is displaying error, then press alt + enter on the drawable item which calls error (for example:"#drawable/vermellstate") and select "Uninject language/reference"
Could be the case that you injected language by mistake.
If you are using Android Studio right click the code in question then->Local History->Show History and revert to a time prior to "Language Injection Configuration Update" .
Hope it helped,
Best of luck !
I am taking the first step into android programming and XML. I am using the Big Nerd Ranch Guide book. In Eclipse, I used the XML given in the book and I got the error XML document structures must start and end within the same entity.
How do I fix this?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="24dp"
android:text="#string/question_text" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/true_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/false_button" />
</LinearLayout>
</LinearLayout>
Problem is solved. I removed the code and saved the xml file. After that, I replaced it with the above code and saved. The error is gone. It was probably a remanant from the time when "automatically build project" was enabled.
Strange.
I just created a new projet, building some layouts, writing some code. Everything was fine except I got this error as shown in the picture below.
I tried to remove and type it again and when typing 'R.id.', there was no 'container' showing up in the list. So that means theres no problem with my R file, just that the 'container' word lost somewhere.
Those code above are actually default code in onCreate() method in your main activity everytime you create a new project in Android Studio. (I actually tried to create a new project to compare and yes it's the same, and without error as it's brand new.).
All I did was comment out the if statement block so the error goes away, and the application has run just fine on the emulator. I just don't know why I got that problem and how I can handle it as I may need to do that in the future. Thank you!
Edit after #Raghunandan has mentioned: Below is my xml.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/provide_information"
android:id="#+id/provideInfoButton"
android:layout_alignParentTop="true" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/take_picture"
android:id="#+id/takePictureButton"
android:layout_below="#+id/provideInfoButton"
android:layout_alignParentLeft="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView"
android:layout_below="#+id/takePictureButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="28dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/classNameTextView"
android:layout_above="#+id/personNametextView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="44dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginBottom="38dp"
android:layout_above="#+id/emailTextView"
android:layout_alignLeft="#+id/emailTextView"
android:id="#+id/personNameTextView" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/emailTextView"
android:layout_alignParentBottom="true"
android:layout_alignLeft="#+id/classNameTextView"
android:layout_marginBottom="82dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/send_button"
android:id="#+id/sendButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
The reason is that I changed the root layout to RelativeLayout (the default of Android Studio was FrameLayout which has an id of "container"). My bad :). Thanks for mentioning about posting the xml file. I have not noticed that as I'm not as familiar with Android Studio as with Eclipse yet.
I am trying to view my android xml file layout design-view but it is not displaying,I did some designing in XML with eclipse and ADT,
When I click on Graphical Layout it does not display anything and says 'Missing Theme',I also tried : Right click XML file>openwith>android layout editor but to no avail.
My development environment is:
Eclipse Helios Service Release 2,
Android Development Toolkit Version: 12.0.0.v201106281929-138431,
Dalvik Debug Monitor Service Version: 12.0.0.v201106281929-138431,
Traceview Version:12.0.0.v201106281929-138431.
What can be the problem` ?
My xml file as below
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/RelativeLayout01"android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView android:id="#+id/ScrollView01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout1">
<RelativeLayout android:id="#+id/RelativeLayout02"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<RelativeLayout android:id="#+id/RelativeLayout05"
android:layout_below="#id/RelativeLayout04" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="#color/brightblue">
<TextView android:id="#+id/TextView06"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="#string/SaveMyBackupTo" android:textColor="#color/black"
android:textStyle="bold" android:layout_marginLeft="5dip"
android:lines="2" android:layout_alignParentLeft="true"
android:singleLine="false" android:layout_toLeftOf="#+id/Button09"
android:layout_marginTop="5dip"></TextView>
<CheckBox android:id="#+id/CheckBox01" android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:text="#string/EnableAutoSave"
android:textColor="#color/black" android:layout_below="#+id/Button09"></CheckBox>
<Button android:id="#+id/Button09" android:layout_alignParentRight="true" android:textSize="12dip"
android:layout_width="wrap_content" android:layout_height="30dip"
android:text="Memory Card" android:layout_marginTop="5dip"></Button>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
I uploaded a screenshot here.
one thing i noted that my title-bar selection option menu is not change-able.
Try changing the SDK level/version from the drop-down. it solved this issue for me everytime.
I had the same issue. solution posted here.