1.2, Android Studio creates a module for the new device

The module provides a container for your application's source code, resource files, and app level settings (such as AndroidManifest.xml). Each module can be built, tested and debugged independently.
By using modules, Android Studio can more easily add new devices to your project. In Android Studio, you can create modules for specific platforms, such as Android Wear or Android TV, through some simple steps. Android Studio automatically creates module directories, such as code and resource directories, and build.gradle files for this device.

Create a new module

Add a new module to your project for the new device, as follows:
1. Click File> New> New Module.
2. In the New Module window that appears, Android Studio provides the following device modules:
1) Phone & Tablet Module
2) Android Wear Module
3) Android TV Module
4) Glass Module
Select the type of module you need to create, and click Next.
3. In the Configure your new module window, enter the following details:
1) Application Name: This name is used as the title of the new module running icon.
2) Module Name: This is used as the name of the folder to place source code and resource files.
3) Package Name: This is the Java namespace of the code in the module. It is added to the package attribute of AndroidManifest.xml.
4) Minimum required SDK: used to set the minimum Android platform version supported by your app module.
Then click Next.
4. The next page displays the selected code template according to the module you selected. Select an activity template and click Next. If you don't need an activity, click Add No Activity and then click Finish.
5. If you choose an Activity template, the following does not contain several inputs based on your activity template, such as tired name and layout name. Click Finish when finished.
Android Studio creates all the necessary files needed for the new module, and synchronizes the gradle file of the new module. Adding a module to a new device also requires adding the required dependencies to the build file.
Once the Gradle project is synchronized, the new module will appear in the left panel of the project. If you do not see the new module folder, make sure to use the Android view.

Next step

Once you add a new module, you can change the module code and resources, build configuration and build the module. You can also run and test modules like other applications.

Author: Song Zhihui
personal micro-blog: Click to enter

Guess you like

Origin blog.csdn.net/song19891121/article/details/51721157