I am suddenly seeing an exception being thrown at install time when I use a string resource (@string/my_app_name
) in android:label
under the <application>
tag in AndroidManifest.xml. The exception is only thrown when the app is installed or updated. my_app_name
is used elsewhere in the app without any errors.
My xml files have not been changed recently, but this exception only started appearing relatively recently. It is likely tied to an Android Studio, Gradle, or API update but I am not certain which specific update this exception started appearing with. I am running the most recent stable versions of everything (Android Studio 3.4, Gradle 5.1.1, targeting Android API 28). Restarting Android Studio, cleaning, rebuilding, purging cache, etc. have not helped.
I am certain it is the label attribute, as that is the string referenced, and if I change android:label
from @string/my_app_name
to hardcoded text, the exception disappears. What am I doing wrong?
AndroidManifest.xml (trimmed for brevity):
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mycompany.myapp"
android:installLocation="internalOnly"
android:versionCode="123"
android:versionName="1.23"
>
...permission-related things...
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/my_app_name"
android:theme="@style/Theme.AppCompat"
tools:ignore="GoogleAppIndexingWarning">
<activity
...activity-related things...
</activity>
<service
...service-related things...
</service>
</application>
</manifest>
Strings.xml (trimmed for brevity):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="my_app_name">My App</string>
...
</resources>
logcat output:
2019-04-29 20:29:39.384 22487-22534/? W/PackageManager: Failure retrieving text 0x7f10002a in package com.mycompany.myapp
android.content.res.Resources$NotFoundException: String resource ID #0x7f10002a
at android.content.res.Resources.getText(Resources.java:348)
at android.app.ApplicationPackageManager.getText(ApplicationPackageManager.java:1678)
at android.content.pm.PackageItemInfo.loadUnsafeLabel(PackageItemInfo.java:204)
at android.content.pm.PackageItemInfo.loadLabel(PackageItemInfo.java:194)
at tvw.f(SourceFile:32)
at tvw.c(SourceFile:1)
at txt.c(SourceFile:7)
at ude.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at ifd.run(Unknown Source:5)
at java.lang.Thread.run(Thread.java:764)
from PackageManager exception when string resource used as Android application label
No comments:
Post a Comment