1. Modify the project to be imported into Mudle to match the format of the library
Modify the first line of code in the Bulid.gradle file in the project
Put
Apply plugin: ' Com.android.application '
Revision changed to
Apply plugin: ' Com.android.library '
Then, modify the configuration information in the Androidmanifiest.xml file, which is mainly to remove the configuration of the originally configured project style, as well as the mainactivity configuration, so that this is done to prevent duplication. The following is a comparison of the Androidmanifiest.xml code of my Moudle file (PS: If the following code example is not good control, here the specific deletion of information can be found on the Internet for other relevant articles reference):
<Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.loonggg.lib.alarmmanager.clock"> <uses-permissionAndroid:name= "Android.permission.VIBRATE"/> <ApplicationAndroid:allowbackup= "true"Android:label= "@string/app_name"Android:supportsrtl= "true" > <receiverAndroid:name= "Com.loonggg.lib.alarmmanager.clock.LoongggAlarmReceiver"> <Intent-filter> <ActionAndroid:name= "Com.loonggg.alarm.clock"/> </Intent-filter> </receiver> <ActivityAndroid:name=". Clockalarmactivity "Android:theme= "@android: Style/theme.translucent.notitlebar" ></Activity> </Application></Manifest>
2. Add the following configuration information in the Gradle file that you want to import into the Mudule Project 2.1 Configure Build.gradle file information in the Project app directory
dependencies { Compile filetree (dir: ' Libs ', include: [' *.jar ']) androidtestcompile (' com.android.support.test.espresso:espresso-core:2.2.2 ', { exclude group: ' Com.android.support ', module: ' Support-annotations ' }) compile project (': Mudle-name ') compile ' com.android.support: appcompat-v7:26.+ ' compile ' com.android.support.constraint:constraint-layout:1.0.2 ' compile ' com.android.support:design:26.+ ' compile ' com.android.support:support-v4:26.+ ' testcompile ' JUnit: Junit:4.12 '}
Key line:
Compile project (': Mudle-name ') //mudle-name is the name of the item to import into the Mudle file
2.2 Setting.gradle file information immediately following the configuration item root directory
In the Setting.gradle file, add the project name of the newly configured module, as follows:
The previous code was not changed:
Include ': App '
After the change:
include ': App ' , ': Your module name '
Import module in Androidstudio (simple version)