Failed to find '#attr/shapeAppearanceSmallComponent' in current theme in android studio - android

I am very new to app development and I am facing this error in issue panel in android studio
Failed to find '#attr/shapeAppearanceSmallComponent' in current theme
i am also facing a warning
Missing styles. Is the correct theme chosen for this layout?
After searching on web i found that this is caused by the wrong theme selected in AndroidManifest.xml.
So as i can understand this:
There is a file for every theme and have some values defined in it.
Theme is defined in AndroidManifest file, is a way to tell compiler that theme related values are saved in given file.
For me i have selected wrong theme file and my app is trying to find an attribute #attr/shapeAppearanceSmallComponent which it can't find because it is not available in theme passed in AndroidManifest.
My app want this attribute as i am using something which need this to be defined (maybe like material TextInputLayout).
Still this is my theory, i am no where near any answer
Now things i want to understand.
: Even if there is a problem in my application, i am still able to compile it and deploy on a device and it is running fine, In which case i can have issue because of this error.
If my theory is right than i have few questions:
If i am using some element (Button or EditText), how would i know that which theme does it support
What if i want elements from different themes to be used in a single application.
One more thing i observed is that in drop down menu in design view for activity_main.xml after changing the theme to Material3.dark from MaterialComponents removes the error.
error image
no error image
If i change theme in design layout using drop down menu it won't change automatically in Manifest file. So will it be true to say that changing themes using that drop down menu is just telling me, how my app will look using that theme, and if it is showing an error i shouldn't use that theme and use one which is not giving any kind of render error.
I will post my AndroidManifest or my activity_main if required

Related

What makes buttons purple in Android studio? Plus other odd behaviours for a newbie

In web development, I see how tags have default themes defined in the browser, and I see how they're applied.
However, with Android Studio's themes, I'm really confused. I can define my custom themes using ?attr/myClass, apply it on widgets by android:theme="?attr/yClass", and then assign a colour to that attribute in my day or night theme files.
But, what baffles me, is—that purple. Where does it come from? When I set the theme header to
<style name="Theme.TestingThemes" parent="Theme.MaterialComponents.DayNight.NoActionBar">
purples come for the not night mode.
When I use other styles that come with "default" with Android Studio, I don't see exactly that purple.
Some themes allow me to set my own colours, but some others don't, like the one that I mentioned.
Worst of all that totally blows my mind is: when I open the theme files in app/res/values/themes/* and app/res/values/colors.xml*, I only see less than 10 themes defined. Yet I see Android Studio suggesting to me a long list of colour names! Where do these come from?
I only use Vim as my text editor. I'm drowning in Android studio. It's cool and powerful, but I require some baby-walking assistance.
A default new project created in Android Studio has a colors.xml resource provided in the project (res/values/colors.xml), where the purple_500 and purple_700 you described are defined.
Any other colors and themes you see that aren't in your own project's files are in the AppCompat and Material Components libraries (defined as project dependencies in default new projects), or they're built into Android itself.
In the Projects panel on the left in Android Studio, if you expand External Libraries, you can see all the code libraries that are imported for your project as dependencies (these are defined in app/build.gradle and downloaded from the Web automatically). Among these dependencies are AppCompat and possibly the Material Components libraries, with their own provided resources within.
You can't modify the contents of the libraries. You're intended to customize by extending (making child styles and themes).
If you want to see where a reference is defined in Android Studio (in XML or other languages like Kotlin and Java), you can Ctrl+Click and it will jump to the line that defines it in whatever file it's in.
I've been developing with Android for a year and have honestly never bothered using material buttons.
You can create your own drawable file for the background of the button and then add that drawable to the back of a regular button in a layout. Don't let things like this frustrate you; there are so many ways of achieving the same outcome in Android :D

Using external widget in an android app

AndroidTagGroup is a widget for adding Tags. I am trying to use it in my app. I have added dependency compile 'me.gujun.android.taggroup:library:1.4#aar' , and am using it as
<me.gujun.android.taggroup.TagGroup
android:id="#+id/tag_group"
style="#style/TagGroup" />
But the layout is not getting rendered and is giving two errors,
Failed to find style 'tagGroupStyle' in current theme and Missing styles. Is the correct theme chosen for this layout? . I cant find any other theme related to TagGroup, the theme i am using is appTheme. I tried defining TagGroup style in the styles.xml, but no use.
Edit
The render error is shown in Android studio studio. Even if i build and run the app, I cant see the widget in the app.
Edit 2
As #CommonsWare suggested, after adding Tags i can see the widget in app. Only issue remaining is the rendering issue, which from the comments seems like a android studio issue.

How can I keep my theme xml file synced with the Xamarin Android designer?

Some background:
I was trying to implement a toolbar by replacing the ActionBar, I accidentally inherited the new theme from a noActionbar theme, so I went to try and update the parent theme, but it didn't fix the problem because Xamarin didn't synchronize that change with the designer window. I decided at this point to just start from scratch, so I went to delete the theme file, and I removed the reference from the manifest, but now I've still got the theme hanging around in the designer, image below:
Again, there is no longer a theme file, and building this as is doesn't generate a new theme file, and the manifest isn't referencing the theme either, so why does the theme hang around? Am I just flat out using themes incorrectly? I'm following exactly what every tutorial online says to do, so I'm not sure how this could be the case. Does the designer have nothing to do with the theme files you create? And if this is the case, why does Xamarin generate a theme file from the designer?

Some style/theme attributes are not available in Android Studio

I recently started to learn Android development. But when I click themes, to change it, it says:
Rendering problems. Missing styles....
Then I can't push any Layout or view into the app.
I tried clicking Auto add all the missing attributes, but it doesn't do anything.
One of them works though - only the Manifest Theme.
These screenshot might help:
Screenshot 1
Screenshot 2
See in the image click on Overscan then the dialog is propmt change the Theme to Holo light the error will disappear.
Image :

Android Studio 1.2.1.1 - Failed to find style 'textViewStyle'

I'm new to Android development and I just installed Android Studio version 1.2.1.1. I created a project, HelloWorld, and chose the default blank activity, Darcula theme, and default API. Straight out of the box, without having written any code or touched anything, I get this message:
"Rendering Problems
Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. Failed to find style 'textViewStyle' in current theme (4 similar errors not shown)."
I uninstalled and reinstalled Android Studio but I still get this error so I'm not sure what else I should do. It says "use the theme combo box... or fix the theme style references" and I'm new to Android Studio so I have no idea where the box is or how to change the reference.
Simply click on the Refresh icon at the review pane:
Android gives you the option to define your own style format, which the default project you made did. It created a style named 'textViewStyle'.
If you look at the text view instead of the design view (you can switch by pressing the tab at the lower left in the part where you get the error that it can't render) you will see that the textView or the app itself contains a line android:theme="#style/textViewStyle".
You can either remove this line, or track down the error in the styles.xml file in the res/values folder. This is the file that defines the style for the app.
If this doesn't help you it could be that the style is defined in your AndroidManifest.xml file, look at the tag, it will contain a line saying android:theme="#android:style/textViewStyle", change that to android:theme="#android:style/Theme.DeviceDefault" and you should be good to go.
More info on custom themes: http://developer.android.com/guide/topics/ui/themes.html
Since you are a beginner, more on general Android development:
http://developer.android.com
Make sure to select the correct theme from the menu in the preview panel.
If you set the layout file to be FullScreen in the manifest but select something like NoActionBar theme in the preview panel, you will also get this error.
Go to manifest file, check the theme you are using there and pick the same in the Design view of your xml file.
Rebooting Android Studio did the trick for me. I couldn't find the "Refresh" button in the accepted answer for some reason.
Click on "Design" tab
On the right pannel, search for the objet "text" that contains something like "#string/hello_world"
Remove this value from the field
There's no more error.

Categories

Resources