I see a lot a similar questions R.java can't compile , No resource found that matches #android:style/ "just after SDK & ADT update" leading to existing projects can't compile
The R.java file cannot be compiled. I find out the errors come from referencing
<style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper" >
<item name="android:colorForeground">#fff</item>
</style>
What is happening is that some styles, like Theme.Wallpaper are not public. You should not extend from them anymore.
Some suggest to revert to platform_tools_r05
http://groups.google.com/group/android-developers/browse_thread/thread/550fce9670530d9b/9b2b2aa389dce367?show_docid=9b2b2aa389dce367&pli=1
If you want to do the correct way
read Xavier July 28
http://groups.google.com/group/android-developers/browse_thread/thread/550fce9670530d9b/9b2b2aa389dce367?show_docid=9b2b2aa389dce367&pli=1
If you wish to reuse a style that is private, you should copy the
content of that style into your own instead of extending it.
Ok so Where do I find the content of the (private) style ?
Seriously, after an update I don't have time to correct platform mistakes when the project code worked right.
<!-- Default theme for windows that want to have the user's selected
wallpaper appear behind them. -->
<style name="Theme.Wallpaper">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
Looks like you want to use the above code from the Android source and create your own theme based it.
Related
What causes the following error in the layout preview in Android Studio?
Rendering Problems The following classes could not be found:
- android.support.v7.internal.app.WindowDecorActionBar (Fix Build Path, Create Class)
Tip: Try to build the project.
The Actionbar has been deprecated and replaced by Toolbar. That being said, you can do the following if you want to continue using Actionbar for now:
Open styles.xml in the values folder inside the res folder.
Add the word Base to the beginning of the theme name so that it reads "Base.Theme.AppCompat.Light.DarkActionBar"
I had the same issue today and this solution worked for me. FYI I am in Android Studio though, but hopefully,the solution is similar for Eclipse.
FYI here is a decent blog post on replacing the Actionbar with the Toolbar for when you are ready to do so: https://blog.xamarin.com/android-tips-hello-toolbar-goodbye-action-bar/
I think you must be depending on "com.android.support:appcompat-v7:23.1.1" in your module settings.
ActionBar has been deprecated.
Just change your dependencies from 'com.android.support:appcompat-v7:23.1.1' to 'com.android.support:appcompat-v7:23.0.1' in "build.gradle".
You can also change your style parent to "Theme.AppCompat.Light.NoActionBar".
Try to use the Toolbar instead of ActionBar.
This one works for me
Changing AppTheme parent in res/values/styles.xml resolved this problem. Replace
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
with
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
Or you can change API level 21 from list.
goto: res-->values-->styles(V21)-->
Code
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
select your theme as Apptheme.NoActionBar in preview. Because ActionBar is depricated, welcome back to ToolBar. NO need to change your dependencies in build.gradle(Module:app).
from com.android.support:appcompat-v7:23.1.1 to com.android.support:appcompat-v7:23.0.1.
Hope this will help you!!!
I had a similar issue, and as many have said since ActionBar has been deprecated the trick was to specify
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
NOTE: that the parent ends in .NoActionBar.
Since ActionBar has been deprecated Android has gone into using ToolBar which you can read about here on the developer.android.com
I tried specifying
<style name="AppTheme.NoActionBar">
As a another post stated and that threw errors. Though others may not have that issue.
I have the same problem in Android Studio 1.5 (even with AppCompatActivity), and my attempt to solve the problem was to update my Android Studio to 2.0. It solves the problem in my case. You can found the link download in: http://tools.android.com/download/studio/canary/latest
thanks #joshgoldeneagle, worked in AS v1.4 for me. also effective in AS is to open "build.gradle (Module.app)" and change version from v7.23.1.1 to v7.23.0.1 -hth
Quick fix
Select a theme with no AtcionBar in UI Preview Tool
You will need to change the api rendering level to 17, there may be rendering problem with higher level apis, might be higher level apis suppose to have a default theme, and hope you are not specified none.
For AS v1.4 adding "Base" before Theme.AppCompat.Light.DarkActionBar in the styles.xml folder solved the problem
Additionally, updating to AS v2.1 also solved the problem. Which is better likely depends on collaborators and their AS version.
In res/values/styles.xml, you will find your AppTheme as below :-
Change it to :-
by adding "Base" the rendering issue will get resolved.
Changing the theme in the manifest solved my problem.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
In android 4.2 we have the possibility to select theme in device settings.
Default theme is equivalent to using #android:color/holo_blue_light as main color.
The question is what tag to use in order to get main color (blue_light, mint, mocha, raspberry) in my own style? If I use #android:color/holo_blue_light, when user switches to mint, part of user interface is in mint color (parts not modified by myself) and part in blue_light (parts modified by myself). I spent many many hours and it's seems there is no any solution.... Perhaps any workaround....?
I even tried to analyse Android styles and theme sources and still no answer:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
At the end I'm posting part of my style code (on the request of one users here):
<style name="MyActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showHome</item>
<item name="android:background">#android:color/holo_blue_light</item>
<item name="android:backgroundStacked">#android:color/holo_blue_light</item>
<item name="android:backgroundSplit">#android:color/holo_blue_light</item>
</style>
Instead of using #android:color/holo_blue_light i should use probably something like #android:color/holo_main_color but the problem is it seems not to exist.
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 mapViewStyle in current theme.
I tried every solutions available to solve this problem but nothing seems to work. I have included library in the manifest file. I even created style is styles.xml, I have chosen Google Apis build target as well.
Can somebody please give me a solution?
here 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"
style="#style/AppTheme"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.maps.MapView
android:id="#+id/themap"
style="#style/mapViewStyle"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="here i have my key"
android:clickable="true"
android:enabled="true" />
</RelativeLayout>
Here is my manifest snippet:
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Second" />
<activity android:name=".Third" android:theme="#android:style/Theme.Black"/>
</application>
here is my style.xml file
<resources>
<style name="mapViewStyle" parent="#android:style/Theme.Black">
</style>
</resources>
For Android Studio (or IntelliJ IDEA),
If everything looks OK in your project and you're still receiving the error in your layouts, try to 'Invalidate caches & restart'.
Enjoy a coffee while Android Studio is recreating caches & indexes.
I had the same problem and found it was the Theme dropdown at the top of the graphical layout editor. I changed from Holo to Theme and the layout displayed and error disappeared.
What I usually do is the following: a Gradle Clean, Rebuild and Sync all my Gradle files. After that I restart Android Studio, and I go to:
Select Theme -> Project Themes -> AppTheme
This is because you select not a theme of your project. Try to do next:
If we are creating too many projects using Android Studio sometime Rendering issue comes. Even creating a blank activity we receive such rendering error.
Please shut down and restart Android studio. In case the issue persists you can
Hope this helps. It works similar fashion as rule of thumb, in case all looks good and still error persists a restart of application usually resolves the issue.
In my case the problem occurred while the default setting for Android Version in the Designer was set to 'Preview N'. Changed Android Version to '23' and the error notification went away.
Edit And don't forget to uncheck 'Automatically Pick Best'.
I had the same problem using Android Studio 1.5.1.
This was solved by using the Android SDK Manager and updating Android Support Library, as well as Local Maven repository for Support Libraries.
After updating the SDK and restarting Android Studio, the problem was rectified.
Hope this helps anyone who has the same problem after trying other suggestions.
I solved it by changing "classpath" in "dependencies" in build.gradles.
Just change:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0-alpha2'
or something like that to:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
I got this error after overriding action bar style like this. Also i lost action bar in preview.
<style name="general_app_theme" parent="#style/Theme.AppCompat">
<!-- for API level 11 -->
<item name="android:actionBarStyle">#style/action_bar_style</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">#style/action_bar_style</item>
</style>
<style name="action_bar_style" parent="#style/Widget.AppCompat.ActionBar">
<!-- for API level 11 -->
<item name="android:height">#dimen/action_bar_height</item>
<item name="android:background">#color/action_bar_color</item>
<item name="android:displayOptions">showTitle</item>
<!-- Support library compatibility -->
<item name="displayOptions">showTitle</item>
</style>
So, problem is overriding theme by my custom. this is the reason, why I've changed AppCompat (from "Project Themes") to general_app_theme (from "Manifest Themes"). Now I have no this error and action bar in preview come back.
Try switching the theme in the design view to one of the options in "Manifest Themes". I'm guessing this is Because you are inheriting the theme from the manifest to support multiple api levels. It worked for me anyway.
With reference to the answer provided by #Benno:
Instead of changing to a specific theme, you can simply choose 'DeviceDefault' from the theme menu. This should choose the theme most compatible with the emulated device.
If you still have the problem after trying all the solutions above, please try modify the API Level as shown below. Incorrect API Level may also cause the problem.
It can be fixed by changing your theme in styles.xml from
Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
to
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
and clean the project. It will surely help.
Most of the errors in XML happen due to the names you have given to the resources.
Images stored in the drawable folder need to be named in a proper manner.
just check these things:
Are there any duplicate files? if so remove the duplicates. (For example "image.jpg" and "image.png" are not allowed in the same time. It will not show any errors but sometimes it will show that R.java cannot be resolved)
Do the filenames contains any uppercase letters? If so right click on that file->refactor->rename
and rename it with all lowercase, no hyphens, and only a-z and 0-9 are allowed.
Just make sure of the above cases.
I got the same problem with my customized theme that used Holo.Light as its parent. In grayed text Android Studio indicated that some attributes were missing. When I added these missing attributes as follows, the rendering problems went away -
<item name="android:textEditSuggestionItemLayout"></item>
<item name="android:textEditSuggestionContainerLayout"></item>
<item name="android:textEditSuggestionHighlightStyle"></item>
Even though they introduced errors in my style's theme, they caused no problems in rendering the activity designs or building my app.
You can simply remove this error through change "App theme" and select any theme such as light. This error will be removed.
I meet the same problem.Select theme to another one in preview can solve problem temporary.Like the image
Finally,I found out that there are AppTheme and AppBaseTheme in my styles.xml.
And AppTheme has parent AppBaseTheme.
The AppBaseTheme has parent of one system style.
And every layout file use the theme AppTheme.
Just change AppTheme's parent to AppBaseTheme's parent.
It solve the problem permanent.
Just need click button 'AppTheme', and choose 'Manifest Themes'. It works in most cases.
For me, it was occurring on menu.xml file as i was using android:Theme.Light as my theme, So what i did was -
Added new Folder in res directory named values-v21.
Added android:Theme.Material.Light as AppTheme in styles.xml.
This is very late but i like to share my experience this same issue.
i face the same issue in Android studio i tried to some other solution that i found in internet but nothing works for me unless i REBUILD THE PROJECT and it solve my issue.
Hope this will works for you too.
Happy coding.
Change your App theme to AppCombat..
I am getting following error on deploying one of the sample projects given by android: android api demos for api level 8 :
error: Error retrieving parent for item: No resource found that matches the given name 'android:style/Theme.Wallpaper'.
at values/styles.xml line 43
<style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper">
<item name="android:colorForeground">#fff</item>
</style>
I have been looking for solutions for over a month now. I have tried rebuilding project, dowloading entire source code again and rebuilding and cleaning.
Help
As Very Well Explain by raychenon.
<style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper" >
<item name="android:colorForeground">#fff</item>
</style>
What is happening is that some styles, like Theme.Wallpaper are not public. You should not extend from them anymore.
Some suggest to revert to platform_tools_r05 HERE
If you want to do the correct way read Xavier July 28 HERE
If you wish to reuse a style that is private, you should copy the
content of that style into your own instead of extending it.
ANSWER
Default theme for windows that want to have the user's selected
wallpaper appear behind them.
<style name="Theme.Wallpaper">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
Looks like you want to use the above code from the Android source and create your own theme based it.
Hope it Will Helps you.
You can refer to this question posted here and read Xavier's comments on the Google blog..
style reference after SDK and ADT plugin update in mid 2011
Hope it helps..Keep me posted
When you import the Android Samples via "Android projects from existing code", I noticed that the libraries and API number are Android 1.5 and API level 3.
This API Level doesn't support android:style/Theme.Wallpaper.
I fixed it by adjusting the Project Build Target to Android 2.2 (API Level 8) in the Project Properties Menu.
Re this example from the Android developer blog
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html
It says that to style the tabs on the action bar, to use a style like this:
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBarView_TabView">
<item name="android:background">#drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
It references a parent style of "android:style/Widget.Holo.Light.ActionBarView_TabView" - which my project is unable to locate. I'm building against v3.2, with a min sdk of platform 8 (v2.2). I'm using ActionBarSherlock.
Am I doing something wrong, or is the sample code incorrect? What style can I inherit from?
Am I doing something wrong, or is the sample code incorrect?
The sample code was correct at the time and no longer is correct.
#Macarse has a blog post with the fix. Quoting Xav's comment on the related issue:
What is happening is that some styles, like WindowTitle are not public (you won't find them in android.R.style). You should not be extending non public resources. aapt used to let you do that but it was a bug which was fixed in platform-tools r6.