Android Library打包成aar,提供給第三方引用
影片4yfc9HEC-h8
看了很多說明文件,始終不知道如何在Android直接建立一個新的Module模組,經過摸索後,發現建立模組前必須建立一個project專案才可以
建立專案後又要建立模組,這時會出現類似有兩個專案,但這樣是不對的,於是發現建立專案後,直接改CODE可以換成模組
1. Sart a new projects
2.隨便選一個activity
3.重要的來了,點選 gradle(Module:app)
把package換成library
找到代碼
apply plugin: 'com.android.application'
修改
apply plugin: 'com.android.library'
找到代碼
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.chiunwu.myapplication"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}修改
compileSdkVersion 23
buildToolsVersion "27.0.3"
defaultConfig {
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}找到代碼
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'修改
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 'com.android.support:appcompat-v7:23.+'
testCompile 'junit:junit:4.12'同步專案後(右上角會有小小的圖示SYNC)
這時已經發現圖示已經以之前不同
點選manifests.xml
找到代碼並刪除
android:roundIcon="@mipmap/ic_launcher_round"找到代碼並刪除
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
這時可加入你要的東西
最後rebuild project
完成
來源http://www.netyea.com#網頁設計 #網站架設 #關鍵字優化 #網頁優化 #App程式設計 #AIOT物聯網
頁:
[1]