Holo theme missing when importing support-v7-appcompat - android

When I import the Support Library v7 into my workspace in eclipse, I get this error:
error: Error retrieving parent for item: No resource found that
matches the given name '#style/ Theme.Holo.Light'.
I have another library project that both link to the appcompat library. The funny thing is that I can build and run my project fine when I remove the styles.xml for values-v14. So I can work without Holo theme but it seems really strange that I lose the styles that should be there?
I'm working in eclipse with latest ADT. I've tried cleaning my project, closing / opening eclipse and the project and re-importing the appcompat into my workspace. Also setting the build target to 19 for both of the linked library projects
Any help would be appreciated

Try using Theme.AppCompat.Light instead reference

It appeared to be a problem with Eclipse/ADT and I have fixed it now. Basically I had previously removed the values-v14/styles.xml file and then at a later date copied the values-v11/styles.xml back into the values-v14 folder. However it didn't properly recognise that it was now in v14 styles.
The solution was to delete the values-v14/styles.xml and add a new one.

Related

Xamarin.Android: Error APT0000: Error retrieving parent for item: No resource found that matches the given name '#android:style/Theme.AppCompat'

I'm trying to use the CoordinatorLayout in my Xamarin.Android app. I've been using a custom theme with Theme.Material.Light as its parent, which worked fine before I added the CoordinatorLayout. When I add it, I get an error telling me I have to use a Theme.AppCompat theme, but as soon as I do the app fails to build and gives me the following error:
/{project directory}/Resources/values/Styles.xml(0,0):
Error APT0000: Error retrieving parent for item:
No resource found that matches the given name
'#android:style/Theme.AppCompat'. (APT0000) (TnpApp.Android)
This answer suggests installing the major version of the support library that matches the Android SDK I'm using. I've tried this (I think I did everything correctly), but it doesn't help.
Does anyone have any ideas?
I'm using Xamarin Studio on Mac.
UPDATE 1
I tried the following code in MainActivity.cs in a clean Xamarin.Android project, and build fails with the same error.
namespace ThemeTest
{
[Activity(Label = "ThemeTest", MainLauncher = true, Icon = "#mipmap/icon", Theme = "#android:style/Theme.AppCompat.Light")]
public class MainActivity : Activity
{
// ...
}
}
UPDATE 2
I removed all the folders from /user/.local/share/Xamarin except for Mono for Android and zips as suggested in this answer. I closed Xamarin Studio and reopened it. I tried to deploy the app, and Xamarin reinstalled all the packages but the build failed with the original error.
I was able to fix this problem by simply removing #android:style/ from the style element's parent tag in my Styles.xml file. So what looked like this...
<style name="MyCustomTheme" parent="#android:style/Theme.AppCompat">
Now looks like this...
<style name="MyCustomTheme" parent="Theme.AppCompat">
I'm shocked the solution is this simple, but it works. :) I got the idea from this code.
I'm developing in Visual Studio 2015/Xamarin and saw this same problem. While I still don't understand the cause or the fix for this problem, this thread did point me in the right direction which seems to have more to do with resaving styles.xml (for my development environment) than anything else.
My styles.xml did not have #android:style/ and I still had the error mentioned above. As described in another proposed solution, I added
<style name="MyCustomTheme.Base" parent="Theme.AppCompat" />
before <style name="MyCustomTheme" parent="Theme.AppCompat">, saved styles.xml and rebuilt my project without errors. I then removed
<style name="MyCustomTheme.Base" parent="Theme.AppCompat" />,
resaved styles.xml and rebuilt with no errors. Visually, my styles.xml is unchanged, but the error is gone.
If you recently installed a google play service related package (firebase for example , but there are many others) , it is possible that this installation messed up with your CSproj and your package.json files (look at your version control history to see if these files were changed), and modified your target api version : Going from target Api 25 to Target 26 for exemple etc.
If this is the case , you should adresse this problem one of two ways :
make sure you download the sdk version that you are now targeting , to do this , go to TOOLS > SDK manager.
or revert back to your old target , by discarding the change the package made to you csproj and package.json files and clean and rebuild.

A 'value' attribute is required for <enum> or <flag> in appcompat-v7

I have been working on project without any issues and all of the sudden this error pops up when I try to build app. I tried deleting build folder, making project couple of times, invalidating android studio cache, restart, uninstaling instaling android studio etc. Please help, since this is driving me crazy :) Thanks!
Error:(1) A 'value' attribute is required for < enum > or < flag >
this is reported for appcompats color.xml file, when I removed appcompat from dependencies problem persisted referencing my project color.xml file, after i commented whole file, it persisted referencing color.xml from one other libraries which I used in project. So i think this is Android studio issue.

Android: Error retrieving parent for item: No resource found #style/Theme.AppCompat.Light.DarkActionBar IntelliJ

Im using Android Support Library v7-AppCompat in my app, i have imported the v7-AppCompat as a library for my app and it works with the code the problem is when i try to apply the AppCompat theme to the app. I have included the modules and the library as well, but still the theme is not working. Even tried copying the themes.xml and theme-base.xml to the values folder but it only results in more errors.
you are using this parent="#style/Theme.AppCompat.Light.DarkActionBar" instead use this parent="#android:style/Theme.AppCompat.Light.DarkActionBar".i guess they have typo in the docs file
Try changing the compile Version of your app to the latest sdk you have installed ie 22 or 23 and it should work.

No resource found that matches the given name '#style/Theme.AppCompat.Light'

I have been on this problem for a couple hours. After downloading a repository from github, the only error in any .xml file is:
No resource found that matches the given name '#style/Theme.AppCompat.Light'
The code is very straightforward, but there is not one straightforward answer I have found, on how to alleviate the error.
here is the code (in file res/values/styles.xml):
<style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light">
<!-- API 14 theme customizations can go here. -->
</style>
The project is located at: https://github.com/erikswed/InstaChatX
I am on Windows, using Eclipse Kepler
What are the steps for that? where is AppCompat located?
Download the support library here:
http://developer.android.com/tools/support-library/setup.html
If you are using Eclipse:
Go to the tabs at the top and select ( Windows -> Android SDK Manager ). Under the 'extras' section, check 'Android Support Library' and check it for installation.
After that, the AppCompat library can be found at:
android-sdk/extras/android/support/v7/appcompat
You need to reference this AppCompat library in your Android project.
Import the library into Eclipse.
Right click on your Android project.
Select properties.
Click 'add...' at the bottom to add a library.
Select the support library
Clean and rebuild your project.
If you are looking for the solution in Android Studio :
Right click on your app
Open Module Settings
Select Dependencies tab
Click on green + symbol which is on the right side
Select Library Dependency
Choose appcompat-v7 from list
The steps described above do work, however I've encountered this problem on IntelliJ IDEA and have found that I'm having these problems with existing projects and the only solution is to remove the 'appcompat' module (not the library) and re-import it.
Below are the steps you can try it out to resolve the issue: -
Provide reference of AppCompat Library into your project.
If option 1 doesn't solve the issue then you can try to change the style.xml file to below code.
parent="android:Theme.Holo.Light"
instead.
parent="android:Theme.AppCompat.Light"
But option 2 will require minimum sdk version 14.
Hope this will help !
Summved

error: Attribute "***" has already been defined when using two library projects in Android

I'm using android-support-v7-appcompat as a library in my Android project. Now I want to include actionbarsherlock as another library project. When I add the second library, it gives so many errors like below
android-support-v7-appcompat\res\values\attrs.xml:476: error: Attribute "attributeName" has already been defined
By changing one attribute value and it's related code snippet is a one solution that I've tried. But when there are nearly 80 lines like above, it will get a messy. Is there any other way I can solve this issue?
The correct way to solve this problem is by updating Android Support Libraries in all relevant projects and library projects. In my case I've used Android support library and also one of the library project to implement my application. When I update both libraries, the problem solved. The way of updating Android support library is;
Right click on the project
Select Android Tools from the pop up window
Select Add Support Library
Remove the appcompact support library project from Properties = > Android
Gradle Resource Merger merges all resource folders from all dependencies and place into single folder. In case there are duplicates build process will fail.
Fortunately, if you look below under Output: label, you will find the right path to the problem.
Here is an example
in your case it is
android-support-v7-appcompat\res\values\attrs.xml:476: error: Attribute "attributeName" has already been defined
You can also build your project from command line and get the right path.
attributeName
Inside values\attrs.xml file on line 476 you would find a with property named "attributeName". Most probably it is your own styleable that you have to change to get rid of the duplicate.
So now, when you know the reason, you can locate that property in your project module and replace it with different name.
I solved this by removing appcompact from project, and changing in styles to
<style name="AppBaseTheme" parent="Theme.Sherlock">
I updated the build tools version and resynced, it worked fine.

Categories

Resources