Home » Android » apk – aapt ERROR getting 'android:name' attribute: attribute is not a string value

apk – aapt ERROR getting 'android:name' attribute: attribute is not a string value

Posted by: admin June 15, 2020 Leave a comment

Questions:

As my apk is generated I execute the command aapt dump badging on it. I keep receiving the following error:

application: label=’Name’ icon=’res/drawable/icon_128x128.png’

application-debuggable launchable-activity:
name=’co.package.name.MainActivity’ label=’Name’ icon=” ERROR
getting ‘android:name’ attribute: attribute is not a string value

I’ve tried to add a label name for all activities and remove all other values-xxx folders under /res but in vain. However, if I create a whole new project and generate a new APK, the APK can be executed with the aapt dump badging command successfully.

I compared the printed message of both APK and found a main difference:

Message of Success apk:

application-label:’AppLabel’
application-icon-160:’res/drawable-xhdpi/icon_128x128.png’
application-icon-240:’res/drawable-xhdpi/icon_128x128.png’
application-icon-320:’res/drawable-xhdpi/icon_128x128.png’
application: label=’AppLabel’
icon=’res/drawable-xhdpi/icon_128x128.png’
application-debuggable
launchable-activity:
name=’com.demo.testApp.MainActivity’ label=” icon=’

Message of Failed apk:

application-label:’MyApp’
application-label-ja:’MyApp’
application-label-de:’MyApp’
application-label-he:’MyApp’
application-label-zh:’MyApp’
application-label-fi:’MyApp’
application-label-nl:’MyApp’
..
.. (all languages would be attached, and finally the error occurs)
..
application: label=’MyApp’ icon=’res/drawable/icon_128x128.png’
application-debuggable
launchable-activity:
name=’com.name.myapp.MainActivity’ label=’MyApp’ icon=”
ERROR
getting ‘android:name’ attribute: attribute is not a string value

—– Edit ——
I found there’s no relevance to “Language” issue. I modified my Manifest file and make sure there is no such “application-label-XX” printed out, and the error is still the same.

Below is my Manifest file

Maybe there’s a wrong format or typo in my Manifest file?

—— Edit —-
I also consider maybe it’s a issue of decoding. In my environment I use utf-8. Maybe something is wrong within the build process of transforming XML to binary file?

If there’s anything unreasonable suspect on above I sincerely apologize. I’ve stuck on this issue three days and really can’t reach a progress. Tried a lot of things and the error is always the same. Any suggestion or comment would be really appreciated.

How to&Answers:

Do you mean this may also be caused by a broken aapt tool?

Sure. The Android tools have had plenty of bugs, historically, and there’s no reason to assume that aapt dump badging is somehow perfect. In fact, your very issue has already been filed as a bug. So, unless you are also seeing some problem in your app’s execution that might be tied in here, I’d assume that aapt dump badging is the item with the issue, not necessarily your app.

If you have not yet updated to the R22 tools, you might do so, to see if this bug has been fixed and they simply have not closed the issue. If you are on the R22 tools, you might add a comment to that issue, pointing this out, and include a link to this SO question, so the tools team has another data point in terms of the problem.

Answer:

Same story here. I got this message when I uploaded a working apk to google play. I was able to reproduce it with the aapt command (in …\android-sdk\platform-tools). It turned out to be a String resource in the name for an intent filter, and was fixed by hard coding it.

It would have taken me a loooooong time to debug this without this answer 🙂

Answer:

If you are using Gradle and you want your substitution to be based on one of your build flavors, you can use a custom substitution string instead of using Android @string references. (http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-Placeholder-support)

In your build.gradle file, define a value for each build flavor in a “manifestPlaceholders” section:

Then you can use “proFreeString” as a substitution in your Manifest file:

Answer:

I have the same problem and I have solveed it by remove the @string from manifex.xml.

Original(error):

string.xml

Manifex.xml

Above would be work fine as expected. But when I upload apk to google play it will cause the aapt ERROR getting 'android:name' attribute: attribute is not a string value

The problem was solved as following :

Fixed:

Manifex.xml

You just need to update the @string to exact string.
Hope this would help you!

Answer:

check action name

change to

Answer:

Dropping this here so that maybe it will help others finding this issue…

The link in @CommonsWare’s original answer is now broken, but it apparently pointed to the shortcoming that other answers have stated explicitly: you can’t use string resources as an action in your manifest. The simple answer is to hardcode the string, but if you want to keep your code DRY, you can centralize the string value in your build.gradle:

(This goes in your root android{} section.)

Then you reference that string in your manifest using syntax like what @Blake Buckley suggested:

…and in your Java code, it’s just an ordinary resource reference:

Answer:

I just had the same problem. It was caused by a string that could not be found.

android:label=”@string/app_name_launcher”

that string in the folder values/strings.xml simply didnt exists.

Funny thing is, I could create the .apk file nevertheless.

Answer:

Basically as the error message suggest, to solve this just go through every line of your Manifest file and make sure every “android:name” has a properly linked “string value”.

Better still hard type the required string for every “android:name” attribute in the Manifest file to debug the problem.