Is something like this possible?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="@string/package_name"
android:versionCode="1"
android:versionName="@string/version_name">
The code above gives me an error:
C:\android-sdk\tools\ant\build.xml:539: Application package '@string/package_name' must have a minimum of 2 segments.
My strings are defined in res/strings.xml like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My app</string>
<string name="version_name">1.00</string>
<string name="package_name">com.mycompany.myapp</string>
If I replace @string/package_name
with the name of the package, android:versionName
seems to be set correctly.
So the question is why package name doesn't work while android:versionName
works?
Edit: Is there any way to use a package name specified in external file?
xml is a resource file used to hold name/value pairs of strings.
A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings: String. XML resource that provides a single string.
It allows you to easily locate text in your app and later have it translated. Strings can be internationalized easily, allowing your application to support multiple languages with a single application package file (APK).
Format string XXX is not a valid format string so it should not be passed to String.
AFAIK, you may only access XML resources using the @resource/name
format for attributes defined in the android
xmlns (http://schemas.android.com/apk/res/android
).
As package is not defined in the android schema, it cannot access resources that way, while versionName can.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With