Rendering Problems Couldn't resolve resource #id/search_edit_frame - android

Rendering Problems Couldn't resolve resource #id/search_edit_frame
This is the rendering error I'm getting in my xml file. I think it has something to do with my support.v7.SearchView below is my xml:
<RelativeLayout
android:id="#+id/layout_ricerca"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#drawable/search_border_backgroud"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="20dp">
<android.support.v7.widget.SearchView
android:id="#+id/testo_ricerca"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:queryHint="#string/search_hint"
android:textSize="25sp"
android:layout_marginStart="5dp"
android:iconifiedByDefault="false"/>
<ImageButton
android:id="#+id/tasto_ricerca"
android:background="#color/trans"
android:layout_marginTop="2dp"
android:layout_width="45dp"
android:layout_height="match_parent"
android:layout_marginEnd="3dp"
android:scaleType="centerInside"
android:layout_alignParentEnd="true"
android:src="#drawable/tasto_ricerca"/>
</RelativeLayout>
When I change the <android.support.v7.widget.SearchView to <SearchView the error disappears, but that's not a good solution for me because I would have to change all my java code to work with the SearchView instead of the android.support.v7.widget.SearchView.
Does anyone know how to fix this problem ? why does it happen? I don't think there is anything wrong with my xml.
Edit:
Added screenshot of the error

To resolve this issue, provide an
android:id="#+id/search_edit_frame"
attribute to a parent view such as
android.support.design.widget.AppBarLayout
or any ViewGroup that is parent to your SearchView.
For example:
<android.support.design.widget.AppBarLayout
android:id="#+id/search_edit_frame"
android:layout_width="match_parent"
android:layout_height="#dimen/my_app_bar_height">
<android.support.v7.widget.SearchView
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.AppBarLayout />

When you have lot of cache memory data are store in Android Studio that time this type of error is coming..
There are many way to solve it.
Quickest way to do that is File → Invalidate caches / Restart...
→ Just Restart.
Right click on project and Synchronize ...Project
click on Build menu --> select Clean Project and then Rebuild
it.

use this code
<SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/searchView"
android:iconifiedByDefault="true"
android:queryHint="Search"
android:layout_centerHorizontal="true" />

android:id="#+id/search_edit_frame"
add above line to parent layout that did the trick for me

Here is an easy one solution.
There is no need of invalidating cache Or restarting.
Just add below line into your strings.xml file and problem will get solved.
<item name="search_edit_frame" type="id"/>
Bingo!

I have the same problem but in eclipse IDE and I solved it by
1- click on project --> clean and it solved the problem with me

Related

Unable to find certain views in my .axml layout file

I got compilations errors in the activity class that says " edit_password ID not found" as well as the other IDs in the same .axml file. Does anyone know why?
<android.support.design.widget.TextInputLayout
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/basic_button_background"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
>
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
app:passwordToggleEnabled="true"
android:id="#+id/edit_password"
android:textSize="#dimen/margin_padding_size_medium"
android:privateImeOptions="#string/abc_action_mode_done"
/>
</android.support.design.widget.TextInputLayout>
Save your .axml file ,clean and rebuild your project. It should then regenerate the Resources.designer.cs file which should include your Id definition.
I found the answer :)
You are right. I have forgotten to add this link you have mentioned:
xmlns:app="http://schemas.android.com/apk/res-auto"
but in addition to it, I had to use android:inputType="textPassword" so the toggle work
Thanks a lot for inspirations :)

Execution failed for task 'app:process:DebugResources'

So out of the blue I've ran into this problem. This is the Gradle Build console output:
https://i.stack.imgur.com/YxvfR.png
I've checked some posts online (mostly SO). So far I've changed the buildToolsVersion (which it doesn't let me be lower than 25.0.0), did Clean Builds, Restarts, checked all XML files for problems.
Nothing solved it. Also I didn't find anything about the first few errors ("No resourse matches..."). I tried to change those files to delete those lines but 1)"They're not part of the project" 2)If I change in anyway there's another error.
I've also returned to previous builds of my code, which worked and somehow now they all show the same errors.
Can you point me in the right direction? I want to understand what's wrong and how can I solve this?
[UPDATE]
Here's the code for res\layout\abc_list_menu_item_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.view.menu.ListMenuItemView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeightSmall">
<!-- Icon will be inserted here. -->
<!-- The title and summary have some gap between them, and this 'group' should be centered vertically. -->
<RelativeLayout
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="?attr/listPreferredItemPaddingLeft"
android:layout_marginRight="?attr/listPreferredItemPaddingRight"
android:duplicateParentState="true">
<TextView
android:id="#+id/scale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:textAppearance="?attr/textAppearanceListItemSmall"
android:singleLine="true"
android:duplicateParentState="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
<TextView
android:id="#+id/shortcut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/title"
android:layout_alignParentLeft="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:duplicateParentState="true" />
</RelativeLayout>
<!-- Checkbox, and/or radio button will be inserted here. -->
And this one's for res\layout\abc_popup_menu_item_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.view.menu.ListMenuItemView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/dropdownListPreferredItemHeight"
android:minWidth="196dip"
style="#style/RtlOverlay.Widget.AppCompat.PopupMenuItem">
<!-- Icon will be inserted here. -->
<!-- The title and summary have some gap between them, and this 'group' should be centered vertically. -->
<RelativeLayout
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:duplicateParentState="true"
style="#style/RtlOverlay.Widget.AppCompat.PopupMenuItem.InternalGroup">
<TextView
android:id="#+id/scale"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textAppearance="?attr/textAppearanceLargePopupMenu"
android:singleLine="true"
android:duplicateParentState="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
style="#style/RtlOverlay.Widget.AppCompat.PopupMenuItem.Text" />
<TextView
android:id="#+id/shortcut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/title"
android:textAppearance="?attr/textAppearanceSmallPopupMenu"
android:singleLine="true"
android:duplicateParentState="true"
style="#style/RtlOverlay.Widget.AppCompat.PopupMenuItem.Text" />
</RelativeLayout>
<ImageView
android:id="#+id/submenuarrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:scaleType="center"
android:visibility="gone" />
<!-- Checkbox, and/or radio button will be inserted here. -->
The difference of these two to the res\merged\debug\SAME_NAME is none other than an error on the line xmlns:android="http://schemas.android.com/apk/res/android"saying URI is not registered. Since both of these files were created automatically I have no idea what's going on. I've searched this last "URI not registered" error but all the solutions presented are so different and seem so specific to one's project that they don't seem to apply here. I tried using Build Variant "release" and then changing it back but nothing happened again.
This happens out of the blue for me as well. I'm paying attention as to why that happened, but the solution is to clear the build cache.
To execute the task, select View > Tool Windows > Terminal from the menu bar and use one of the following commands:
For Windows: gradlew cleanBuildCache
For Mac or Linux: ./gradlew cleanBuildCache
For future reference and related options, check out this link:
Clear the build cache
Now, I finally got this to work but have simply no idea why or how it started working. So I had this ListView in one of my layouts and I wanted to add another in other layout. For some reason, when I created the second it changed the IDs of the first (one of them was 'title').
I deleted both ListViews but the problem persisted. So when I realized that I had the ListView with a 'title' id I decided to do it again with the first IDs and now everything works.
Couple of questions:
Why did the second ListView changed the first's IDs? - I created a Layout for the ListViews and seperate adapters since I wanted to show them in different ways.
Why deleting the layouts and the adapters did not solve the issue at first?
Plus, I still have an issue which is related. When I press the 3dots on the Toolbar (overflow), the app crashes. It throws a NullPointerException at ListMenuItemView. When I go to one of the faulty files in the question it says that it Cannot find the declaration of android.support.v7.view.menu.ListMenuItemView... Any ideas on what's going on?

rendering error; couldn't resolve #id/search_edit_frame

I am having an error that says couldn't resolve #id/search_edit_frame I don't know why,
I tried the File>Invalidate Caches> Just Restart and restart android studio also tried to change the render version all of my supported api..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
myapp="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.SearchView
android:id="#+id/svSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textColor="#color/textDefault"
myapp="#string/search_hint"
myapp="false" />
</LinearLayout>
I'm using Android Studio 1.2.2 and sure that it compiles android.support.v7.widget(AppCompat)
any help will be appreciated.. thanks
Use
<SearchView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/searchView"
android:iconifiedByDefault="true"
android:queryHint="Search"
android:layout_centerHorizontal="true" />
it should work
First, you can search #id/search_edit_frame in all your xml file to check where it comes from.
Second, if you are sure that there is no #id/search_edit_frame in your xml, then you can try to delete all files in your Build folder.
Try to clean your project also.

Android Image on Image button not displayed

I facing the problem that, I cant add new image button to my XML file.I added my icons to Drawable, but It cannot show in image button. XML shows an error ImageButton class not found. How can I solve this ?
I got the following error in xml
The following classes could not be found:
- ImageButton (Change to android.widget.ImageButton, Fix Build Path, Edit XML)
Here is my xml
<?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:orientation="vertical" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="109dp"
android:src="#drawable/facebook" />
</RelativeLayout>
Why dont you try a simple button instead of image button. Here is a code i have on some of my buttons with image.
android:drawableTop="#drawable/three" : this is basically the image
android:background="#drawable/buttonstyles" : this is a style for the button. No need to use it. Or the other layout features i have.
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/button2"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:background="#drawable/buttonstyles"
android:drawableTop="#drawable/three"
android:onClick="goToSettings"
android:text="Settings" />
I was using the interface builder and for some reason, it added this
tools:src="#drawable/ic_play_arrow_white_100dp"
Change it to this to make it work and display image in image button
android:src="#drawable/ic_play_arrow_white_100dp"
I had the same problem. My images were .ico and I had the same error message in the Graphical Layout tab in eclipse. I proved to transform the .ico images to .png images and then I deleted the .ico and I imported the .png to the project.
It was succesful.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="109dp"
android:src="#drawable/a" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="164dp"
android:src="#drawable/a" />
</RelativeLayout>
I think this not big issue. Your is right nothing wrong with you posted. In my eclipse it works fine.
First check images properly put in drawable folder with small letter naming convention. or if you only have it in /res/drawable-xhdpi/ please check this also. May use this background instead of src.
if you not not getting R cannot resolve with putting image in xml, then first Refresh project, if is not work then clean whole project, if this is also not work restart eclipse.
if you restart eclipse, then it not work, may be your project library not properly located.
Change extend Activity to extend AppCompatActivity in your Activity Class
You need to define the Button as ImageButton in java classes.

RelativeLayout not working properly Android

I have the next problem: I use a lot the RelativeLayout, like the Android documentation is telling me to do. But, since few days, I don´t understand why, this is not working anymore:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#drawable/background"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/boton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/boton"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
</RelativeLayout>
This is my layout, very simple. So, according to this one, the textView should be BELOW the button, but, instead, it appears OVER the button!
.
Сan anyone explain me what happens?
EDIT: The problem is not when I try to run it on a device, the problem comes when I see it on the graphical layout of the ADT Plugin for Eclipse...
I try this code it's working properly.
If your side not working properly Try to Clean build your project and then Run.
If still having problem then Try this
android:layout_below="#+id/boton"
remove above line with this
android:layout_below="#id/boton"
Because "+" create new reference to R.java file
This may be the issue.
try by removing the below line from your code
android:layout_marginTop="60dp"
Take the '+' sign out of the TextView's layout_below attribute. The '+' tells it to deine a new id. Without the '+' it should refer to the existing one.
I think your issue is the drawable for the background, since I am not seeing an image in your preview.
Having this issue is giving you a build error so the preview doesn't show the layout in its current state (it reverts to the last sucessful build). Either remove that line and save to see the preview or check to make sure that you have an image in your drawables folder titled "background"
Try this, without the drawable to check if it is working for you:
<?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" >
<Button
android:id="#+id/boton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Button" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/boton"
android:layout_centerHorizontal="true"
android:layout_marginTop="60dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#000" />
</RelativeLayout>
I am trying to run it, and now, I know what´s the problem.
When running the app in a terminal, it is working properly, the problems comes when I try to see it on the graphical layout on the ADT plugin on Eclipse! Anyone with the same problem??
Add </RelativeLayout> at the end of your relative layout to close it.

Categories

Resources