To add module dependency in Android Studio, follow these steps:
- Open the Project Structure: In Android Studio, go to “File” > “Project Structure” (or press “Ctrl + Alt + Shift + S”).
- Select “Modules” from the left-side menu.
- Select the module you want to add a dependency to.
- Click on the “Dependencies” tab.
- Click on the “+” button at the bottom of the window.
- Select “Module Dependency.”
- From the list of modules, select the module you want to add as a dependency.
- Click “OK” to add the dependency.
- Finally, click “Apply” and then “OK” to save the changes.
Once you’ve added the module dependency, the new module’s resources and classes will be available in the dependent module. You can also use gradle to manage dependencies between modules, by adding the required dependencies in the build.gradle file for each module.
Easy way to add module dependency
The easiest way to add a module dependency in Android Studio is by using the Project Structure dialog. Here are the steps:
- Open the Project Structure dialog: Go to the “File” menu and select “Project Structure”.
- Select the module you want to add the dependency to: In the Project Structure dialog, select the module you want to add the dependency to from the list on the left side.
- Go to the Dependencies tab: In the main panel, select the “Dependencies” tab.
- Add a new dependency: Click the “+” button in the top right corner of the panel. Select “Module Dependency”.
- Select the dependency module: From the list of modules, select the module you want to add as a dependency.
- Apply and close the Project Structure dialog: Click “Apply” and “OK” to close the Project Structure dialog.
That’s it! The selected module should now be added as a dependency in your project. You can now use the classes and resources from the dependency module in your code.