0

I have working app in Android Studio (gradle) that have assets DIR where I keep my graphics and etc... I have created a wearable app that works but I have the same assets , libs ,etc that I have in my main app. In other words, I have the same files copied in assets and libs dir in both my main app and my wearable app.

How can I avoid this and make my wearable app use the same assets and libs?

Adrian Ivasku
  • 1,118
  • 3
  • 16
  • 31

1 Answers1

1

You need to create a library module separate from either (wearable or handheld) app, and put the common assets and libs in there. Let's call that module commonLibrary. Then you set both apps up to reference it. So in both apps' build.gradle file, include the following:

dependencies {
    compile project(':commonLibrary')
    // other dependencies go in here as well
}

For more information on library modules, see http://developer.android.com/tools/projects/index.html#LibraryModules

Sterling
  • 6,365
  • 2
  • 32
  • 40
  • Thank you, this is what I was looking for. But there is a problem. From the documentation you provided :Library modules cannot include raw assets The tools do not support the use of raw asset files (saved in the assets/ directory) in a library module. Any asset resources used by an application must be stored in the assets/ directory of the application module itself. However, resource files saved in the res/ directory are supported. - So I can`t make the commonLib to have assets ? – Adrian Ivasku Apr 25 '16 at 18:42
  • That documentation is out of date. Assets couldn't be included in library projects with Eclipse, but using Gradle, they can: http://stackoverflow.com/a/6527926/252080 – Sterling Apr 25 '16 at 19:01
  • 1
    Ok. I`l follow this. Cheers – Adrian Ivasku Apr 25 '16 at 19:07