简体   繁体   中英

Android Common Resource as library for Android Application with Modular structure

I have Android res folder with some xml and images.

What need to be done

Need to put all common resources in separate module and other module will be referring this module for UI creation.

What i have tried

I have created Android Library Module and kept only res folder and in my Android Instant App project structure. I have given the reference of Android Library in base module build.gradle. As other module have already reference of app module in their respective build.gradle then ideally it should work but its not working

Error: Android Linkage failed

In your settings.gradle add this:

include ':yourLibraryName'
project(':yourLibraryName').projectDir = new File(settingsDir, '/path/to/yourLibraryName')

Then go to your projects' build.gradle file and add this in the dependency:

dependencies{
    implementation project(':yourLibraryName')
}

Then you should be able to access library's files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM