[英]ERROR getting 'name' attribute: attribute is not a string value
Uploading my apk file to google play makes this error:将我的 apk 文件上传到 google play 会导致此错误:
Your APK cannot be analyzed using aapt.
无法使用 aapt 分析您的 APK。 Error output: Failed to run aapt dump badging: ERROR getting 'name' attribute: attribute is not a string value
错误输出:无法运行 aapt 转储标记:获取“名称”属性时出错:属性不是字符串值
Since I know that this problem is within my manifest file, I have put it here:因为我知道这个问题在我的清单文件中,所以我把它放在这里:
AndroidManifext.xml: 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>
I have checked all android:name
attributes and couldn't find the problem.我已经检查了所有
android:name
属性,但找不到问题。 Thank you all.谢谢你们。
so after searching a little I have found three options for you to do:因此,经过一番搜索后,我找到了三个选项供您执行:
1- if you have something as follows (which I see you don't ): 1-如果您有以下内容(我认为您没有):
<intent-filter>
<action android:name="@string/alarm_auto_sync" >
</intent-filter>
you should hard code the string and remove @string你应该对字符串进行硬编码并删除@string
2- follow this bug to see what could and have been done to solve this issue as I found out this might be the bug of 2- 关注这个错误,看看可以和已经做了什么来解决这个问题,因为我发现这可能是
aapt dump badging
aapt 转储徽章
3- if you have values-fa and values-en and other string values as such you should copy your android:name to values. 3- 如果您有 values-fa 和 values-en 以及其他字符串值,您应该将您的 android:name 复制到值。
for more information on these options visit this question or this question有关这些选项的更多信息,请访问此问题或此问题
hope this helps希望这可以帮助
check this link from google从谷歌检查这个链接
android:name="string"
the document says , your syntax of android:name
element should be String .该文件说,你的
android:name
元素的语法应该是String 。
i think , your manifest file project is good .我认为,你的清单文件项目很好。 check your manifest library .maybe you add some library and get this error .
检查您的清单库。也许您添加了一些库并收到此错误。 also check your project and your library have
android:name
element .还要检查您的项目和您的库是否有
android:name
元素。
hope this help you .希望这对你有帮助。
All thing seems good in your AndroidManifest.xml
except xmlns:tools="http://schemas.android.com/tools"
position.除了
xmlns:tools="http://schemas.android.com/tools"
位置之外,您的AndroidManifest.xml
所有内容似乎都很好。 Please give a try by moving xmlns:tools="http://schemas.android.com/tools"
from <application></application>
tag to <manifest></manifest>
tag like this.请尝试将
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>
Hope this will work for you :)希望这对你有用:)
This is how you have defined your custom permission:这是您定义自定义权限的方式:
<permission
android:name="ir.altontech.newsimpay.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
But in the docs you can see:但在文档中你可以看到:
You need to supply both a label and description for the permission.
您需要为权限提供标签和描述。
I'm not sure whether this may be the case, but at least docs urge you to define label and description .我不确定是否是这种情况,但至少文档敦促您定义label和description 。
If you are using any library project as module in your project that having如果您在项目中使用任何库项目作为模块,
android:label="@string/app_name"
in their string.xml
file then it may coause of your problem.在他们的
string.xml
文件中,那么它可能会导致您的问题。
So your pass hardcode app name in your manifest file for app name like below.因此,您在清单文件中将应用程序名称硬编码为应用程序名称,如下所示。
android:label="PASS YoUR APP NAME HERE not from string.xml"
You can go for below suggested link.您可以访问以下建议链接。 I hope it helps you.
我希望它能帮助你。
aapt ERROR getting 'android:name' attribute: attribute is not a string value aapt 错误获取“android:name”属性:属性不是字符串值
Thank you谢谢
If your app is multi-lingual, then make sure you have provided the translatable as false in the string.xml or provide the app_name in the other files as well.如果您的应用程序是多语言的,请确保您在 string.xml 中提供了可翻译为 false 或在其他文件中也提供了 app_name。 I too got this error once and that was the cause.
我也遇到过一次这个错误,这就是原因。
可能是您的班级已移至另一个包检查您的所有班级是否都在与清单相同的包路径中
android:name="ir.altontech.cloudmessaging.core.pushnotification.PushNotificationService"
First of all, try to follow java naming convention首先,尽量遵循java命名约定
Since from your code I cant realy tell is your Application Class
an Enclosing class由于从您的代码中我无法确定您的
Application Class
是一个封闭类
Try using .Classes.Model.AnalyticsApplication
instead of ir.altontech.newsimpay.Classes.Model.AnalyticsApplication
尝试使用
.Classes.Model.AnalyticsApplication
而不是ir.altontech.newsimpay.Classes.Model.AnalyticsApplication
I think this issue is for different reasons for different people.我认为这个问题针对不同的人是出于不同的原因。 But in all cases it is the
android:name
attribute that needs to be investigated.但在所有情况下,都需要调查
android:name
属性。 When I encountered it and read some of the replies here, I found mine.当我遇到它并阅读这里的一些回复时,我找到了我的。 Adding it here, just so that it can help someone in future.
在这里添加它,只是为了将来可以帮助某人。
<intent-filter>
<action android:name="@string/broadcast_action" />
</intent-filter>
I had defined broadcast_action
in strings.xml
It worked when I changed that to a hardcoded string.我在
strings.xml
定义了broadcast_action
当我将其更改为硬编码字符串时它起作用了。 AAPT does not accept a string reference here. AAPT 不接受此处的字符串引用。
For me the issue was that the broadcast intent-filter name which was referenced from the string file was deleted.对我来说,问题是从字符串文件中引用的广播意图过滤器名称被删除。 If you are using multi-module project check all manifest in Android Studio to see an error.
如果您使用的是多模块项目,请检查 Android Studio 中的所有清单以查看错误。
android:name
can refer to any android:name
attribute, not just the one in application tag. android:name
可以指任何android:name
属性,而不仅仅是应用程序标签中的那个。
Merged manifest can be found at可以在以下位置找到合并的清单
app/build/intermediates/merged_manifest/<flavour>
In Android we need to assign the strings through string.xml file.在 Android 中,我们需要通过 string.xml 文件来分配字符串。
String name - "xyz app"
this is not the recommended approach这不是推荐的方法
String name = "@string/app_name"
In String.xml Store this name as在 String.xml 中将此名称存储为
<string name="app_name">xyz app</string>
complete in android programming we need to follow this approach for using strings在android编程中完成我们需要遵循这种使用字符串的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.