Import module in AndroidStudio (simple version ),

Source: Internet
Author: User

Import module in AndroidStudio (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 bulid. gradle file of this project

Set

apply plugin: 'com.android.application'

Change

apply plugin: 'com.android.library'

Then, modify the configuration information in the AndroidManifiest. xml file. Here, we mainly Delete the configuration such as the previously configured project Style and MainActivity configuration to prevent duplication. The following uses the AndroidManifiest. xml code of my Moudle file as the reference code (PS: if the following code examples are difficult to compare, you can refer to other related articles for specific deletion information here ):

<manifest xmlns:android="http://schemas.android.com/apk/res/android"          package="com.loonggg.lib.alarmmanager.clock">    <uses-permission android:name="android.permission.VIBRATE"/>    <application        android:allowBackup="true"        android:label="@string/app_name"        android:supportsRtl="true"        >        <receiver android:name="com.loonggg.lib.alarmmanager.clock.LoongggAlarmReceiver">            <intent-filter>                <action android:name="com.loonggg.alarm.clock"/>            </intent-filter>        </receiver>        <activity            android:name=".ClockAlarmActivity"            android:theme="@android:style/Theme.Translucent.NoTitleBar"            ></activity>    </application></manifest>

 

 

2. Add the following configuration information to the gradle file of the Mudule project to be imported. 2.1 configure the build. gradle file information in the app directory of the project.

 

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 indicates the name of the project to be imported into the Mudle file.

 

2.2 configure the setting. gradle file in the root directory of the project.

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

Code before modification:

include ':app'

After the change:

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.