I'm using two 3rd party libs, both use the same attribute name in their attrs.xml. The build fails with:
Attribute "tabBackground" has already been defined
Is there a way to work around this collision without modifying the argument name in one of the libs?
Actually no.
I suppose you have a dependency from A project to B.
When you build your main project in Eclipse, the resources will fail to build and an error is printed out in the Android console: "... error: Attribute "icon" has already been defined".
Actually you have two ways :
remove dependency from A project to B
OR change attribute name of some project
Also if you build project with Gradle you can use this article which explains how to merge resources.
Related
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.
I have to use 2 ANEs in my android project.
When I attach 2nd ANE Flash Builder shows a lot of such problems:
Error occurred while packaging the application:
aapt tool failed:C:\Users\***\res\layout\anesample.xml:8: error: Error: No resource found that matches the given name (at 'text' with value '#string/cnn').
All of them are with #string problem.
All strings are present and in the res\values\strings.xml.
Both ANEs work well in another project but I could not find a difference between this projects.
What's wrong?
ANEs work fine together fhen I recompiled one of them with different name of strings.xml, i.e. srings-fb.xml.
But you can imagine situation when every ANE library is compiled not by yourself…
I copy appcompat folder from Android SDK extras v7 folder and create a Android library module in my project. Compiling project I get errors, first one being appcompat/res/layout/abc_action_mode_close_item.xml:17: error: Error: No resource found that matches the given name (at 'contentDescription' with value '#string/abc_action_mode_done'). Looks like appcompat needs mediarouter resources as well. So I create a Android library module mediarouter. I set mediarouter as a dependency for appcompat library. Compile. Now I get the error mediarouter/res/values/styles.xml:18: error: Error retrieving parent for item: No resource found that matches the given name 'Widget.AppCompat.ActionButton'. I add depenency appcompat to mediarouter. Compile. Now I get the errors
appcompat/res/values/attrs.xml:32: error: Attribute "windowActionBar" has already been defined
Help!
You just need to add "#string/abc_action_mode_done" in your appcompat/res/values/strings.Do not "set mediarouter as a dependency for appcompat library".(In my case,"#string/abc_action_mode_done" already exists in the appcompat/res/values/strings.I don't know why you miss it.)
"add depenency appcompat to mediarouter" is necessary.
I stumbled across this problem and it seems to be a bug in IDEA:
when you create the library module, IDEA will create some boilerplate files in the new module. During this operation, IDEA will overwrite the strings.xml resource file with some kind of template strings.xml-file intended for newly created android applications (IDEA will also create other stuff you don't want or need).
There are two workarounds:
1. Create the library module in IDEA first and copy the appcompat-resources afterwards into the existing library module directory
2. Just make the sub folders readonly before you create the library module in IDEA. This will prevent IDEA from changing the files in the library.
After that, the library module compiled on my machine.
All,
I am attempting to use an existing open-source project (we'll call it A) within my app as a library. Project A also comes with its own library project (B). Project A compiles and runs just fine; however, when I try to use A within my app (I checked the 'Is Library' within A and added A to my app) I get several errors that "No resource identifier found for attribute 'X'in package..." These particular attributes exist within B. I even checked that they were added to R within A, and in fact, they were.
My question: why doesn't my app see that these resources exist?
I've searched all over and found only one situation like mine:
Android library not pulling its resources through to other projects
but I do not see that any of my resources are named the same.
I'm using Eclipse with ADT v20.0
I appreciate any help!
EDIT: If it's helpful, the open-source app I'm trying use is AnySoftKeyboard (ASK). I've also tried creating a new project and adding ASK as a library -- no dice.
EDIT2: Part of making ASK a library required converting several switch statements to if-else statements because R Ids are not declared as final for libraries.
The errors are apparently due to the usage of custom attributes in the AnySoftKeyboard project that you converted to a library. I found that a solution is recently added into ADT (on Rev 17), mentioned in this answer.
As instructed, I tried replacing all instances of
"http://schemas.android.com/apk/res/com.menny.android.anysoftkeyboard"
with
"http://schemas.android.com/apk/res-auto"
in the newly converted library project and was able to build and run an app which includes the project (didn't really test any functionality though).
Hope this helps.
I followed the instructions here on how to create an Android library project, and use it in an Android application:
http://developer.android.com/guide/developing/eclipse-adt.html
but it is not working. I can see the library project is added to my application but I cannot reference anything in it because it won't build. The R.java file from the lib is NOT being added to my application project, so the lib project contains tons of errors, everywhere it tries to reference it's own R.java file.
I don't know if this has anything to do with it, but in the console there are messages stating that the there is "No resource identifier found for attribute 'X' in package 'Lib Package'. My library package has a a few styleable attributes defined for a custom view I made, all of which are being complained about in this console message. The library builds just fine, and I don't get those messages in the console until I hook the library to my application, so I don't know what's up with this.
I really would like to get this working. I've spent two entire days on it, to no avail. Please offer any ideas you might have to help!
The answer to my conundrum was that the library had an attrs.xml file that defined a few custom attributes for a custom view I created. I removed attrs.xml and hardcoded the values in the custom view code, rebuilt the library, and problem solved.
This isn't cool though, what this means is that custom views with custom attributes can't be used in libraries. I hope Google fixes this.
It's actually a matter of file duplicity. You can't build a project that contains more than one instance of the same file. Due to the nature of an android project XML files are usually the first the negate a successful build.