9

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

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="co.package.name"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <supports-screens android:anyDensity="true" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- Location -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <!-- Camera -->
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <uses-feature
        android:name="android.hardware.camera"
        android:required="true" />
    <uses-feature
        android:name="android.hardware.camera.front"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />

    <!-- GCM Necessary -->
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <permission
        android:name="co.package.name.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="co.package.name.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <!-- Calendar R/W -->
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon_128x128"
        android:label="@string/app_name"
        >
        <!-- GCM meta-data -->
        <meta-data
            android:name="com.arrownock.push.SERVICE_TYPE"
            android:value="GCM" />
        <meta-data
            android:name="com.arrownock.push.gcm.SENDER_ID"
            android:value="@string/gcm_project_id" />
        <meta-data
            android:name="com.arrownock.push.APP_KEY"
            android:value="@string/light_appkey" />

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/fb_id" />

        <activity
            android:name=".Main"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="co.package.name.SplashHP"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.SettingsHP"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="co.package.name.LocationSelect"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name="co.package.name.SettingOptionAlarm"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.SettingOptionNotify"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.SettingOptionShare"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="settingshare"
                    android:scheme="oauth" />
            </intent-filter>
        </activity>
        <activity
            android:name="co.package.name.HpCalendar"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.SMSList"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.SMSEditor"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.SMSChooseToSend"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.ShareToFB"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.ActPOI"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>

        <activity
            android:name="com.facebook.LoginActivity"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>
        <activity
            android:name="co.package.name.LogInOutFB"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
        </activity>

        <activity
            android:name="co.package.name.LoginTwitter"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="t4jsample"
                    android:scheme="oauth" />
            </intent-filter>
        </activity>

        <receiver
            android:name="co.package.name.AlarmReceiver"
            android:exported="true" >
            <intent-filter>
                <action android:name="@string/action_alarm" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </receiver>

        <!-- GCM Service -->
        <receiver
            android:name="com.arrownock.push.AnPushGCMReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>

                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="co.package.name" />
            </intent-filter>
        </receiver>
        <service android:name="com.arrownock.push.GCMIntentService" />

        <receiver
            android:name="co.package.name.ExtendedReceiver"
            android:exported="true"
            android:icon="@drawable/icon_128x128"
            android:label="Receiver" >
            <intent-filter>
                <action android:name="com.arrownock.push.PushService.MSG_ARRIVAL" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

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.

trooper
  • 4,444
  • 5
  • 32
  • 32
KunYu Tsai
  • 632
  • 1
  • 10
  • 15
  • Show your full manifest. My guess is that you have a typo in your manifest or maybe in one of your resource files – CocoNess Jun 09 '13 at 10:18
  • Do you have any evidence of a problem with *your app*? This could just as easily be a problem with **`aapt dump badging`**. – CommonsWare Jun 09 '13 at 10:54
  • @TanjaV I've attached my Manifest file. I would also examine my string file. – KunYu Tsai Jun 09 '13 at 12:18
  • @CommonsWare Thanks for the information. Do you mean this may also be caused by a broken aapt tool? However, other application could be dump badging successfully. Or I should reinstall the aapt tool? Could you please kindly give me more detail information of this? Thanks! – KunYu Tsai Jun 09 '13 at 12:22
  • 1
    How could google still not fix this issue is beyond me. They have this lousy message here https://support.google.com/googleplay/android-developer/answer/3470652?hl=en. My app is scripted to build different apps from the same binary. Everything works great except for submission -- because the element name attribute is a variable instead of a single literal. Go figure! – Ephraim Mar 30 '14 at 06:53

8 Answers8

12

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    Maaaaany thanks!!!! This is totally the root reason! I modified the @string references to hard-code in my intent-filter and the problem was solved! As like the description in the issue report, it's really unreasonable that Android run successfully just aapt dump badging failed. I would like to provide my whole month's quota thanks to you for helping me figure out this problem!! Thanks!!! – KunYu Tsai Jun 09 '13 at 13:27
  • 1
    The link in @CommonsWare's original answer is now broken, but we can infer that it pointed to the fact that **you can't use string resources as an `action` in your manifest**. If you don't want to hardcode the value, see my expanded answer below. – Sterling Apr 27 '18 at 19:33
10

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 :)

Stephen Hosking
  • 1,405
  • 16
  • 34
  • Im stuck up with the same issue and I've tried all possible solutions listed on SO but no help. I have tried your solution but in vein. Any help on the same ? – Pramod Solanky Sep 26 '13 at 07:53
  • 1
    Superstar. Thanks. I love you. Nearly chucked computer out of the window: then I tried this in a last-ditch effort. And I sailed through on apk upload on Google Play. – Jon Apr 01 '18 at 07:02
6

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:

productFlavors {
    pro {
        manifestPlaceholders = [
            proFreeString:"my.pro.string"
        ]
    }
    free {
        manifestPlaceholders = [
            proFreeString:"my.free.string"
        ]
    }
}

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

        <intent-filter>
            <action android:name="com.foo.${proFreeString}.ACTION_1" />
        </intent-filter>
Blake Buckley
  • 91
  • 1
  • 2
  • 5
6

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:

def actionDoSomething = applicationId + ".ACTION_DO_SOMETHING"
resValue "string", "action_do_something", actionDoSomething
manifestPlaceholders = [
        action_do_something: actionDoSomething
]

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

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

<intent-filter>
    <action android:name="${action_do_something}" />
</intent-filter>

...and in your Java code, it's just an ordinary resource reference:

Intent myIntent = new Intent(context, DoSomething.class)
        .setAction(getString(R.string.action_do_something)); 
Sterling
  • 6,365
  • 2
  • 32
  • 40
  • 1
    An alternative to `resValue` is `buildConfigField`. This will be more efficient if you only intend to use the string in the manifest and in Java code, and not from other resources. Either approach (`resValue` or `buildConfigField`) is a nice way to address the problem. – CommonsWare Apr 27 '18 at 19:37
4

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

Original(error):

string.xml

<string name="alarm_auto_sync">auto_syncx</string>

Manifex.xml

<intent-filter>
    <action android:name="@string/alarm_auto_sync" >
</intent-filter>

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

    <intent-filter>
        <action android:name="auto_syncx" >
    </intent-filter>

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

Ted Yu
  • 304
  • 3
  • 13
3

check action name

<action android:name="@string/action_restart" />

change to

<action android:name="kr.mint.test.restart" />
Hun
  • 3,652
  • 35
  • 72
0

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.

Tower Jimmy
  • 567
  • 1
  • 4
  • 15
0

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.

S bruce
  • 1,514
  • 3
  • 16
  • 24