1.把要導(dǎo)入成Mudle的項(xiàng)目修改成符合Library的格式
修改該項(xiàng)目中bulid.gradle文件中第一行代碼
把
apply plugin: 'com.android.application'
修改為
apply plugin: 'com.android.library'
然后,修改AndroidManifiest.xml文件中配置信息,此處主要是把原來(lái)配置的項(xiàng)目Style等配置以及MainActivity配置刪除,這樣處理是為了防止重復(fù)。以下以一個(gè)我的Moudle文件的AndroidManifiest.xml代碼作為對(duì)照(PS:如果以下代碼示例不好對(duì)照,此處具體刪除信息可以網(wǎng)上找其他相關(guān)文章參考):
<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.在要導(dǎo)入Mudule項(xiàng)目中的gradle文件中添加以下配置信息
2.1配置項(xiàng)目app目錄中build.gradle文件信息
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'}關(guān)鍵一行:
compile project(':mudle-name') //mudle-name即要導(dǎo)入成Mudle文件的項(xiàng)目名稱2.2緊接著配置項(xiàng)目根目錄中setting.gradle文件信息
在setting.gradle文件中,添加新配置的Module的項(xiàng)目名,具體如下:
未改變之前代碼:
include ':app'
改變之后:
include ':app', ':your module name'
總結(jié)
以上所述是小編給大家介紹的Android Studio中導(dǎo)入module的方法,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VEVB武林網(wǎng)網(wǎng)站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注