亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

android studio如何創建一個子module并引入主工程

標簽:
Android

首先我们new 一个Module:

https://img1.sycdn.imooc.com//5c1e417c0001d69617161140.jpg

在弹出框中选择Library:

https://img1.sycdn.imooc.com//5c1e41a90001248b18001334.jpg


https://img1.sycdn.imooc.com//5c1e41bd00011e4a17801326.jpg

然后press finish:

https://img1.sycdn.imooc.com//5c1e41d000010fd013321314.jpg

https://img1.sycdn.imooc.com//5c1e425a0001069a22461242.jpg

在build.gradle写下面这句话,library就被引用了

compile project(":mylibrary")

有一个地方需要特别注意,这个libary的support-v4包的版本可能跟主版本不一样,那么最好改成跟主版本一样,这样不会有编译问题,很多时候编译问题就在于这些包的版本不一样

这个新建立的libary的build.gradle:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.0"


    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:23.1.1'
    testCompile 'junit:junit:4.12'
    androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

}


https://img1.sycdn.imooc.com//5c1e41bb00011e4a17801326.jpg


點擊查看更多內容
2人點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
全棧工程師
手記
粉絲
6509
獲贊與收藏
303

關注作者,訂閱最新文章

閱讀免費教程

感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消