美文网首页
Android笔记 - Android studio如何添加ar

Android笔记 - Android studio如何添加ar

作者: appppppen | 来源:发表于2018-11-21 10:26 被阅读0次

    (1)将编译好的aar文件放到app/libs下,类似jar的做法。譬如,libs/HDDecodeLibrary_1.1.03_a.aar。

    (2)在工程的当前module的gradle(app/build.gradle)的dependencies节点前添加:

    repositories {    flatDir {dirs'libs'}}
    

    并且在dependencies中添加:

    compile(name: ‘HDDecodeLibrary_1.1.03_a’, ext: ‘aar’)
    

    一个完整的build.gradle例子如下:

    apply plugin: 'com.android.application'
    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.2"
        defaultConfig {
            applicationId "sim.com.scannertest"
            minSdkVersion 24
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabledfalse
                proguardFiles getDefault
                ProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        sourceSets {
            main {
                res.srcDirs = ['src/main/res', 'src/main/res/raw']
            }
        }
    }
    repositories {
        flatDir { dirs 'libs' }
    } 
    dependencies {
        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:25.3.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        testCompile 'junit:junit:4.12'
        compile(name: 'HDDecodeLibrary_1.1.03_a', ext: 'aar')
    }
    

    本文来自 洌冰 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/u011109881/article/details/78544147?utm_source=copy

    相关文章

      网友评论

          本文标题:Android笔记 - Android studio如何添加ar

          本文链接:https://www.haomeiwen.com/subject/faeqqqtx.html