Import module in Android studio (simple version)

1. Modify the project to be imported into Mudle to conform to the Library format

Modify the first line of code in the build.gradle file in this project


apply plugin: ''

Change to

apply plugin: ''

Then, modify the configuration information in the androidmanifest.xml file. This is mainly to delete the original configuration of project Style and MainActivity configuration, so as to prevent duplication. Here is a comparison with the Android manifest.xml code of my cloud file (PS: if the following code examples are not easy to compare, please refer to other relevant articles for specific deletion information on the Internet):

<manifest xmlns:android=""

    <uses-permission android:name="android.permission.VIBRATE"/>
        <receiver android:name="com.loonggg.lib.alarmmanager.clock.LoongggAlarmReceiver">
                <action android:name="com.loonggg.alarm.clock"/>




2. Add the following configuration information to the gradle file in the Mudule project to be imported

2.1 information of build.gradle file in app directory of configuration project


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('', {
        exclude group: '', module: 'support-annotations'
    compile project(':mudle-name')
    compile ''
    compile ''
    compile ''
    compile ''
    testCompile 'junit:junit:4.12'

Key line:

 compile project(':mudle-name')   //Mudle name is the name of the project to be imported into the Mudle file


2.2 next to the setting.gradle file information in the root directory of the configuration project

In the setting.gradle file, add the project name of the newly configured Module as follows:

Previous code unchanged:

include ':app'

After change:

include ':app', ':your module name'

Tags: Android Gradle xml Junit

Posted on Sun, 03 May 2020 04:37:42 -0400 by sebastiaandraaisma