0

Let me give a simple example. An Android Studio project has two modules:

MyApp
MyLibrary

MyApp is an Android app and MyLibrary is an Android library used by MyApp. IMPORTANT:MyLibrary is a module with all the source code. It is a project inside this project.

Here is the mystery. Both MyApp and MyLibrary use the following library:

libraryfoo.aar

libraryfoo.aar is in the libs folder of both modules. However, MyApp's build.gradle has the following:

implementation fileTree(dir: 'libs', include: ['*.aar'])

while MyLibrary's build.gradle has the following:

compileOnly files('libs/libraryfoo.aar')

This is because direct local .aar file dependencies are not supported when building an AAR. librarryfoo has a string value foo. In a layout XML file of MyApp, the following works:

android:text="@string/foo"

However, the same code in a layout file of MyLibrary results in error:

Cannot resolve symbol '@string/foo' 

Could anyone offer a tip to help remedy this problem?

Hong
  • 17,643
  • 21
  • 81
  • 142

0 Answers0