Android Studio中導(dǎo)入module的方法(簡(jiǎn)單版)
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)目名稱(chē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ì)腳本之家網(wǎng)站的支持!
- Android studio 項(xiàng)目手動(dòng)在本地磁盤(pán)中刪除module后,殘留文件夾無(wú)法刪除的問(wèn)題解決方法
- Android Studio徹底刪除項(xiàng)目 Android Studio徹底刪除Module
- Android studio 如何刪除項(xiàng)目 module
- 如何修改Android Studio創(chuàng)建module時(shí)默認(rèn)的compileSdkVersion
- Android Studio導(dǎo)入Project與Module的方法及實(shí)例
- Android Studio 如何刪除/新建一個(gè)module(圖文教程詳解)
相關(guān)文章
Android ContentResolver使用說(shuō)明
這篇文章主要介紹了Android ContentResolver使用說(shuō)明,需要的朋友可以參考下2016-01-01Flutter仿網(wǎng)易實(shí)現(xiàn)廣告卡片3D翻轉(zhuǎn)效果
在逛網(wǎng)易新聞時(shí),發(fā)現(xiàn)列表中的廣告在你滑動(dòng)的時(shí)候會(huì)有一個(gè)3D旋轉(zhuǎn)的交互引你的注意。本文將利用Flutter實(shí)現(xiàn)這一效果,感興趣的可以了解一下2022-04-04android自定義Toast設(shè)定顯示時(shí)間
這篇文章主要為大家詳細(xì)介紹了android自定義Toast設(shè)定顯示時(shí)間,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-08-08Kotlin語(yǔ)言中CompileSdkVersion與targetSdkVersion的區(qū)別淺析
這篇文章主要介紹了Kotlin語(yǔ)言中CompileSdkVersion和targetSdkVersion有什么區(qū)別,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧2023-02-02Android使用AudioManager修改系統(tǒng)音量的方法
這篇文章主要介紹了Android使用AudioManager修改系統(tǒng)音量的方法,結(jié)合實(shí)例形式分析了AudioManager調(diào)節(jié)音量的常用方法及相關(guān)使用技巧,需要的朋友可以參考下2016-08-08在Android模擬器上模擬GPS功能總是null的解決方法
在我們開(kāi)發(fā)時(shí)需要在模擬器上模擬GPS,可在Location的時(shí)候總是null,下面與大家分享下具體的解決方法,感興趣的朋友可以參考下哈2013-06-06Android9.0 SystemUI 網(wǎng)絡(luò)信號(hào)欄定制修改的流程解析
這篇文章主要介紹了Android9.0 SystemUI 網(wǎng)絡(luò)信號(hào)欄定制修改的流程,本文通過(guò)圖文實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-11-11Android studio創(chuàng)建第一個(gè)app
這篇文章主要為大家詳細(xì)介紹了如何使用Android studio創(chuàng)建你的第一個(gè)項(xiàng)目Hello World,感興趣的小伙伴們可以參考一下2016-05-05