Task: Manually add a Java module in Android Studio
Steps
- Switch to Project view.
- In the project root folder, create a folder with a unique identifiable name for the module. This folder becomes the root folder for the module.
- Within the module's root folder, create a
src/main/javafolder. - Within the module's root folder, create a
build.gradlefile. - Within the module's
build.gradle, insert the following two lines:
a.apply plugin: "java" // apply the java plugin
b.sourceCompatibility = 1.8 // Java 8 source compatibility - Add the module to
settings.gradleusing the folder name from step 2.
a.include ':app', ':yourModuleFolder' - Add the module to your application's build.gradle.
a.implementation project('yourModuleFolder') - Synchronize the project and wait for it to rebuild.
- Create a package structure in your module's java folder.
At this point, when you switch back to Android Project view, you should see your new module
below your app's root folder and your module's build.gradle should show up under Gradle Scripts.