首页 > 其他分享 >Android原生插件打包成AAR依赖丢失

Android原生插件打包成AAR依赖丢失

时间:2023-01-18 10:55:45浏览次数:34  
标签:插件 1.0 compileOnly implementation aar AAR android com Android

apply plugin: 'com.android.library'
apply plugin: 'com.kezong.fat-aar'

android {
    compileSdk 30
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildToolsVersion '29.0.2'
    ndkVersion '25.1.8937393'

}

repositories {
    flatDir {
        dirs 'libs'
    }
}


dependencies {
    compileOnly fileTree(dir: 'libs', include: ['*.jar','*.aar'])

    compileOnly fileTree(dir: '../app/libs', include: ['uniapp-v8-release.aar'])

    compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
    compileOnly 'androidx.legacy:legacy-support-v4:1.0.0'
    compileOnly 'androidx.appcompat:appcompat:1.0.0'
    implementation 'com.alibaba:fastjson:1.1.46.android'
    implementation 'com.facebook.fresco:fresco:1.13.0'
    embed 'com.pusher:java-websocket:1.4.1'
    /*implementation 'com.alibaba:fastjson:1.1.46.android'
    implementation 'com.facebook.fresco:fresco:1.13.0'
    implementation 'com.pusher:java-websocket:1.4.1'*/
    /*implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'*/
}

在要打包的model中新增  apply plugin: 'com.kezong.fat-aar' 要引入的依赖前关键字改为 embed 即可

在这之前还需在根目录下的build.gradle文件中添加 com.kezong.fat-aar的引用

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.1'
        classpath 'com.github.kezong:fat-aar:1.3.6'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

 

标签:插件,1.0,compileOnly,implementation,aar,AAR,android,com,Android
From: https://www.cnblogs.com/myvoice/p/17059368.html

相关文章