SoFunction
Updated on 2025-04-04

Methods for importing modules in Android Studio (simple version)

1. Modify the project to be imported into a Mudle to a format that conforms to the Library

Modify the first line of code in the file in the project

Bundle

apply plugin: ''

Modified to

apply plugin: ''

Then, modifyThe configuration information in the file is mainly to delete the original configured project Style and MainActivity configuration, so that the processing is to prevent duplication. The following is a code of my Moudle file as a comparison (PS: If the following code examples are not easy to compare, you can find other related articles to refer to the specific deletion information here):

<manifest xmlns:andro
   package="">
 <uses-permission android:name=""/>
 <application
  android:allowBackup="true"
  android:label="@string/app_name"
  android:supportsRtl="true"
  >
  <receiver android:name="">
   <intent-filter>
    <action android:name=""/>
   </intent-filter>
  </receiver>
  <activity
   android:name=".ClockAlarmActivity"
   android:theme="@android:style/"
   ></activity>
 </application>
</manifest>

2. Add the following configuration information to the gradle file you want to import in the Mudule project

2.1 Configure file information in the project app directory

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 androidTestCompile(':espresso-core:2.2.2', {
  exclude group: '', module: 'support-annotations'
 })
 compile project(':mudle-name')
 compile ':appcompat-v7:26.+'
 compile ':constraint-layout:1.0.2'
 compile ':design:26.+'
 compile ':support-v4:26.+'
 
 testCompile 'junit:junit:4.12'
}

Key line:

 compile project(':mudle-name') //mudle-nameThat is to import intoMudleThe project name of the file

2.2 Then configure the file information in the project root directory

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

Unchanged previous code:

include ':app'

After the change:

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

Summarize

The above is the method of importing modules in Android Studio introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!