Sharing resources with multiple gradle android modules

I have doubts about gradle in Android Studio in a multi-module project.

I need to access the R.class resource in another module. See next example:

Project
   |
   |---App
   |    |---src (Main App)
   |
   |---Core
   |    |---src (Entities App + Database) - Library aar
   |
   |---CommumUI
   |    |---src (Commum user interface) - Library aar
   |

      

AndroidManifest.xml app

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
          package="org.company.project.App">

      

Core AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
          package="org.company.project.Core">

      

CommumUI AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
          package="org.company.project.CommumUI">

      


This app building uses gradle and after that it will generate R.class in:

-App.buid.generated.source.r.debug.org.company.project.App.R.class
-App.buid.generated.source.r.debug.org.company.project.CommumUI.R.class

      

I tried in the App project to get the list of resources in the CommumUI project, but the object will be null.

Example:

//This return null
drawerLayoutList = (ListView) findViewById(R.id.drawer_menu_list);

//That again return null
drawerLayoutList = (ListView) findViewById(org.company.project.CommumUI.R.id.drawer_menu_list);

      

+3


source to share





All Articles