错误获得' name' attribute:attribute不是字符串值

时间:2017-03-26 05:52:54

标签: android android-manifest

将我的apk文件上传到google play会出现此错误:

  

无法使用aapt分析您的APK。错误输出:无法运行   aapt dump badging:错误获得' name' attribute:属性不是   字符串值

因为我知道这个问题在我的清单文件中,所以我把它放在这里:

AndroidManifext.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ir.altontech.newsimpay">

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <permission
        android:name="ir.altontech.newsimpay.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="ir.altontech.newsimpay.permission.C2D_MESSAGE" />

    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

    <application xmlns:tools="http://schemas.android.com/tools"
        android:name="ir.altontech.newsimpay.Classes.Model.AnalyticsApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="false"
        android:theme="@style/AppTheme"
        tools:replace="android:supportsRtl">

        <receiver
            android:name="com.adjust.sdk.AdjustReferrerReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

        <receiver android:name=".Receivers.SmsListener">
            <intent-filter android:priority="1000">
                <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            </intent-filter>
        </receiver>

        <receiver
            android:name="com.google.android.gms.analytics.AnalyticsReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.google.android.gms.analytics.AnalyticsService"
            android:enabled="true"
            android:exported="false" />

        <activity
            android:name="ir.altontech.newsimpay.Activities.Introduction"
            android:screenOrientation="portrait" />
        <activity
            android:name="ir.altontech.newsimpay.Activities.Main"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:taskAffinity="ir.altontech.simpay"
            android:theme="@style/AppTheme"
            android:windowSoftInputMode="adjustPan"/>

        <activity
            android:name=".Activities.SpecificPage"
            android:screenOrientation="portrait">
            <intent-filter>
                <data
                    android:host="ir.altontech.simpay.specific"
                    android:scheme="simpay" />
                <data
                    android:host="ad.simpay.ir"
                    android:scheme="http" />

                <action android:name="android.intent.action.VIEW" />

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

        <activity
            android:name=".Activities.SplashActivity"
            android:launchMode="singleTask"
            android:screenOrientation="portrait"
            android:taskAffinity="ir.altontech.simpay"
            android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".Activities.FastCharge"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait"
            android:taskAffinity="ir.altontech.simpay"
            android:theme="@style/fast_charge_theme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>

        <activity android:name="ir.altontech.newsimpay.Activities.BarcodeScanner" />
        <activity
            android:name="ir.altontech.newsimpay.Activities.FinalTrainTicket"
            android:screenOrientation="landscape" />
        <activity
            android:name="ir.altontech.newsimpay.Activities.VideoPlayer"
            android:screenOrientation="landscape"
            android:taskAffinity="ir.altontech.simpay" />
        <activity android:name="ir.altontech.newsimpay.Activities.CallBack">
            <intent-filter>
                <data
                    android:host="ir.altontech.simpay.callback"
                    android:scheme="simpay" />

                <action android:name="android.intent.action.VIEW" />

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

        <service
            android:name=".Classes.Services.GCMService"
            android:exported="false" />

        <receiver
            android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.google.android.gms.analytics.CampaignTrackingService"
            android:enabled="true"
            android:exported="false" />

        <!-- services -->

        <!-- registration process service -->
        <service
            android:name="ir.altontech.cloudmessaging.core.registrationprocess.RegistrationProcessService"
            android:exported="false">
            <intent-filter>
                <action android:name="co.shariftech.pushnotification.intent.action.START_PUSH_NOTIFICATION_SERVICE" />
            </intent-filter>
        </service>

        <!-- registration process token refresher service -->
        <service
            android:name="ir.altontech.cloudmessaging.core.registrationprocess.RegistrationProcessTokenRefresherService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID" />
            </intent-filter>
        </service>

        <!-- push notification service -->
        <service
            android:name="ir.altontech.cloudmessaging.core.pushnotification.PushNotificationService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>

        <!-- receivers -->

        <!-- google cloud messaging receiver -->
        <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="ir.altontech.newsimpay" />
            </intent-filter>
        </receiver>

    </application>

</manifest>

我检查了所有android:name属性,但无法找到问题。谢谢大家。

11 个答案:

答案 0 :(得分:2)

所以在搜索了一下后,我找到了三个选项:

1-如果您有以下内容(我认为您不会):

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

你应该对字符串进行硬编码并删除@string

2-跟随this bug看看解决这个问题可以做些什么和已经做了什么,因为我发现这可能是

的错误
  

aapt dump badging

3-如果你有值-fa和values-en以及其他字符串值,你应该将你的android:name复制到值。

有关这些选项的详情,请访问this questionthis question

希望这会有所帮助

答案 1 :(得分:1)

google

查看此链接
      android:name="string"

文档说,android:name元素的语法应为字符串

我认为,您的清单文件项目很好。检查你的清单库。你可以添加一些库并得到这个错误。还要检查您的项目,您的库中有android:name元素。

希望这对你有所帮助。

答案 2 :(得分:1)

AndroidManifest.xmlxmlns:tools="http://schemas.android.com/tools"位置外,所有内容似乎都很好。请尝试将xmlns:tools="http://schemas.android.com/tools"<application></application>标记移至<manifest></manifest>标记,如下所示。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ir.altontech.newsimpay"
    xmlns:tools="http://schemas.android.com/tools">

<application
    android:name="ir.altontech.newsimpay.Classes.Model.AnalyticsApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="false"
    android:theme="@style/AppTheme"
    tools:replace="android:supportsRtl">
</application>

希望这对您有用:)

答案 3 :(得分:1)

这是您定义自定义权限的方式:

<permission
    android:name="ir.altontech.newsimpay.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

但在docs你可以看到:

  

需要提供权限的标签和说明。

我不确定是否会出现这种情况,但至少文档会敦促您定义标签说明

答案 4 :(得分:1)

如果您使用任何库项目作为项目中具有

的模块
 android:label="@string/app_name"

在他们的string.xml文件中,可能会导致您的问题。

因此,您在清单文件中传递硬编码应用名称,如下所示。

 android:label="PASS YoUR APP NAME HERE not from string.xml"

答案 5 :(得分:1)

您可以查看以下建议的链接。我希望它可以帮助你。

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

谢谢

答案 6 :(得分:1)

如果您的应用是多语言的,那么请确保您在string.xml中提供了可翻译的false,或者在其他文件中提供app_name。我也得到了这个错误,这就是原因。

答案 7 :(得分:1)

可能是你的班级被移到另一个包检查你的所有类是否都在清单中的同一个包路径

        android:name="ir.altontech.cloudmessaging.core.pushnotification.PushNotificationService"

答案 8 :(得分:1)

首先,请尝试关注java naming convention

从你的代码中我不能真正告诉你的是.Classes.Model.AnalyticsApplication一个封闭的课程

尝试使用ir.altontech.newsimpay.Classes.Model.AnalyticsApplication代替{{1}}

答案 9 :(得分:0)

我认为这个问题对不同的人有不同的原因。但是在所有情况下,都需要调查android:name属性。当我遇到它并在这里阅读一些回复时,我找到了我。在这里添加它,以便将来可以对某人有所帮助。

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

我在broadcast_action中定义了strings.xml,当我将其更改为硬编码字符串时,它可以工作。 AAPT此处不接受字符串引用。

答案 10 :(得分:-1)

在Android中,我们需要通过string.xml文件分配字符串。

 String name - "xyz app"  

这不是推荐的方法

   String name = "@string/app_name"

在String.xml中将此名称存储为

 <string name="app_name">xyz app</string>

在android编程中完成我们需要遵循这种方法来使用字符串

相关问题