AAPT: error: resource android:attr/popupPromptView is private - android

I am using actionbarsherlock library in my android app and I am using one of its style attribute with the name of popupPromptView but when I try to generate the apk for my app, it gives me this error:
C:\Users\My Username\.gradle\caches\transforms-2\files-2.1\fa481916e694bf5a6973eb98ad535c2d\jetified-actionbarsherlock-4.4.0\res\values\values.xml:268:5-296:25: AAPT: error: resource android:attr/popupPromptView is private.
I tried going to this values.xml file and comment out this style attribute but when I try to generate the apk again, that line which I commented comes back again. I don't know what's wrong. I have even tried deleting the cache folder of .gradle but still no luck.

I had the same problem
You can solve downloading Sherlock as a module itself to compile together with your project (I imported the Sherlock modules from a Eclipse project) instead of using a library reference
In this way you can remove that line in a definitive way

it made my day
https://developer.android.com/studio/command-line/aapt2
In previous versions of AAPT, the compiler would silently ignore foregroundInsidePadding attributes when you define it with the android namespace. When using AAPT2, the compiler catches this early and throws the following build error:
Error: (...) resource android:attr/foregroundInsidePadding is private
To resolve this issue, simply replace android:foregroundInsidePadding with foregroundInsidePadding.

Related

Android published library xml attributes not found (AAPT)

** See edit below **
I built a multi-library project and published it to a private repository on jitpack.io successfully. Some of the libraries contain resources in the form of layout files, etc. I have another project that implements these libraries and builds fine, but when I try to run it, I keep getting an error regarding attributes in some of the layout and navigation files (from the libraries):
For instance, I'm loading a layout file called fragment_radio_main that is imported from com.github.username.libraryname:radio:version. In that layout, I have a RecyclerView which uses the attribute app:layoutManager. This is where the failure is happening
AAPT: error: attribute layoutManager (aka com.organization.appname:layoutManager) not found.
AAPT: error: attribute sc_border_width (aka com.organization.appname:sc_border_width) not found.
AAPT: error: attribute sc_corner_radius (aka com.organization.appname:sc_corner_radius) not found.
AAPT: error: attribute sc_tint_color (aka com.organization.appname:sc_tint_color) not found.
AAPT: error: attribute defaultNavHost (aka com.organization.appname:defaultNavHost) not found.
In the above logs, layoutManager was from RecyclerView, the attributes with the prefix sc_* are from a 3rd party library that one of my layouts uses, and defaultNavHost is from NavHostFragment from the Navigation library. There are many more attributes that are failing, but I believe this gets the point across.
In the aka line(aka com.organization.appname:sc_tint_color), the attribute sc_tint_color is not actually an attribute defined by com.organization.appname, but rather, defined by a 3rd party. Maybe there's some configuration that needs to happen to resolve these attributes? I'm just stuck on this.
If you need further info, I'd be glad to provide. Any help would be greatly appreciated.
** EDIT 11/27/2019 **
It turns out that, if I import my Radio library to my current project, I also have to add any 3rd party dependencies my Radio library used that contain resource (specifically, in this case, styleable) files in my current project to gain access to those attributes.
So I guess my question is, does anyone know how to avoid having to do this?
Just add the dependency inside the library as api instead of implementation. Then you'll have it available in the module which references it, without the need to duplicate these dependencies.

Failed linking references - style attribute '#android:attr/textColor' not found in appcompat

I'm trying to get rid of the soon-to-be-removed option android.enableAapt2=false from our project. It's been painful, but I hope I'm getting there.
Now I'm stuck with a BuildException: Failed to process resources, see aapt output above for details.
The issue seems to be this:
error: style attribute '#android:attr/textColor' not found.
Message{kind=ERROR, text=error: style attribute '#android:attr/textColor' not found.,
sources=[/Users/<username>/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/4215c9c9bb2efc5bb086ff343ac44128/res/values/values.xml],
original message=, tool name=Optional.of(AAPT)}
I've found the following question and answer, but I believe it's a bit different when it's not in our own project it's happening: Cannot complete Gradle Build, failed linking references
What's the reason for this happening and how can I solve it?
The specs:
Android Studio 3.1.2
JRE: 1.8.0_152-release-1024-b01 x86_64
buildToolsVersion: 27.0.3
Gradle: 4.6
Gradle plugin: 3.1.2
Edit:
Just in case I removed every single line of styles and attributes from our project and did a clean build and invalidation of cache and restart and everything, but the build was still pointing its finger at the values.xml of com.android.support:appcompat-v7:27.1.1.
I had the same issue and found out that the main problem was that aapt2 did not report the problem location correctly.
Do a global search of all your style xml files for name="#android.
This is part of <item name="#android:...
You need to remove the # character.
I have found this line in one of the files: <item name="#android:textColor">#FF000000</item>
aapt2 reported correctly issues with other locations where it found the # character, but for some reason, it didn't report it correctly in this case.
You may need to search shared files or even library aar files if you have any.

Android same attribute name in two libs, name collision

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.

How do I add the library android-support-v7 in IntelliJ IDEA (Not Android Studio/Gradle)?

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.

QuiltView Error: No resource identifier found for attribute 'scrollOrientation'

I want to use the QuiltView lib in my Android project.
When I try the demo, I've no problems, but when I want to use it in my project I've got this error :
error: No resource identifier found for attribute 'scrollOrientation' in package 'com.jake.quiltview'
I've just include libs (QuiltViewLib & GridLayoutV7) in my project...
So, have you got an idea ?
You have to fix the namespace. The XML he used references his own project. You have to change it to reference yours. I had this issue too.
Change
xmlns:app="http://schemas.android.com/apk/res/com.jake.quiltviewsample
To:
xmlns:app="http://schemas.android.com/apk/lib/com.package.class
Obviously changing it to match your project package. :)

Categories

Resources