Android Module中导入aar

mymodule中未引用aar时,主app中build.gradle写法:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28

    defaultConfig {
       ...
    }

    buildTypes {
        ...
    }

}

dependencies {
    ...
    implementation project(':mymodule')
}

mymodule中引用aar后,主app中build.gradle写法:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28

    defaultConfig {
       ...
    }

    buildTypes {
        ...
    }

}

repositories {
    flatDir {
        dirs '../mymodule/libs', 'libs'
    }
}

dependencies {
    ...
    implementation project(':mymodule')
}

module中的build.gradle写法:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28

    defaultConfig {
       ...
    }

    buildTypes {
        ...
    }

    sourceSets {
        main {
            jni.srcDirs = []
            jniLibs.srcDirs = ['libs']
        }
    }
}

repositories {
    flatDir {
        dirs '../mymodule/libs', 'libs'
    }
}

dependencies {
   ...
    implementation(name: 'myaar.1.0.0', ext: 'aar')
}

你可能感兴趣的:(Android速记)