Can I use a resource string for a package name?

Is 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 above code gives me an error:

C: \ android-sdk \ tools \ ant \ build.xml: 539: The application package '@ string / package_name' must contain at least 2 segments.

My lines are defined in res / strings.xml as follows:

 <?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 replaced @string/package_name with the package name, android:versionName seems to be configured correctly.
So the question is, why does the package name not work while android:versionName working?

Edit: Is there a way to use the package name specified in the external file?

+7
source share
1 answer

AFAIK, you can only access XML resources using the @resource/name format for the attributes defined in android xmlns ( http://schemas.android.com/apk/res/android ).

Since the package is not defined in the Android schema, it cannot access resources this way, while versionName can.

+6
source

All Articles