[Android Studio] 使用本地 aar 文件


導出aar

首先Android Library項目的gradle腳本只需要在開頭聲明

apply plugin: 'com.android.library'

之后就和導出apk文件一樣的方法,執行 ./gradlew assembleRelease,然后就可以在 build/outputs/aar 文件夾里生成aar文件

引用本地的aar

1: 確保你的 aar文件中沒有和現有工程重復的res,包括圖片名字,如ic-launcher, string , dimen等,一旦主工程引用了該重復的資源名稱,就會報錯。 

2: in  build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "xxxxxxxxxxx"
        minSdkVersion 22
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories { flatDir { dirs 'libs' } }
dependencies { compile(name:'app-release', ext:'aar') }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM