Import module in Androidstudio (simple version)

Source: Internet
Author: User

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)

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.