2

Consider following project hierarchy

  • Base
  • Common
  • Flix

We have Base and Common as library project which we are using in several other projects like Flix. We would like to define some sort of property file into Base and Common project and would like to refer the properties defined at Base or Common level into string.xml file of Flix project.

For example

Consider we have a property file named base.properties under "Base/assets" folder with following content

app.props.cms.url=http://test.flixv2.dev.com/api

We have string.xml file into Flix project, where we have a string resource

<string name="cms_url">HERE WE WOULD LIKE TO REFER THE PROPERTY</string>

we have tried following which is not working

<string name="cms_url">${app.props.cms.url}</string>

Please let know your views.

Thanks

Umang
  • 107
  • 7
  • Did you ever figure out a way to do this without making it a string resource? As in reading from the properties file directly? – Adam Johns Aug 28 '15 at 22:13

3 Answers3

0

Are you using any kind of build system like Maven or Gradle? This seems to me like a dependency thing.

ExpensiveBelly
  • 444
  • 5
  • 8
  • No, i am not using maven or gradle. – Umang Jun 26 '14 at 14:32
  • I suggest you start doing it as you're working with different modules in your app. Have a look at this website: https://code.google.com/p/maven-android-plugin/ Basically what you need is this archetype: android-library-quickstart that will show you how to use a library as a dependency in your application. – ExpensiveBelly Jun 26 '14 at 15:15
0

There is another way out, which is not exact solution of my question

Ref: Concatenate multiple strings in XML?

we tried following:

created a string resource in Base project as below

 <string name="app.props.cms.url">http://test.popcornflixv2.device.screenmedia.net/api/</string>

And refer the same into Flix project as shown below:

<string name="cmsservice_url">@string/app.props.cms.url</string>
Community
  • 1
  • 1
Umang
  • 107
  • 7
0

There seems to be a suggestion that the "official way" of doing this (where you insert the package name prefix) does not work. However, this is a very old report, so I would try that first, before the "reflection" approach - both of which are described here:

android import ressources from library project

Community
  • 1
  • 1
IanB
  • 3,489
  • 1
  • 20
  • 24