创建具有多个奥尔斯/ JAR文件的AAR [英] Create an AAR with multiple AARs/JARs

查看:268
本文介绍了创建具有多个奥尔斯/ JAR文件的AAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所看到的问题( Android Studio中结合2 .aar成一个等)发布的各种开发者,但我还没有看到让我能够创建包括1个或多个奥尔斯或JAR文件(我可以做的JAR,因为我并不需要共享的资源的AAR一个明确的回应;只有类)。这里是我的图书馆项目app.gradle:

I have seen questions (Android Studio combine 2 .aar into one and others) posted by various developers but I haven't seen a definitive response that enables me to create an AAR that includes 1 or more AARs or JARs (I can do with JARs since I don't need to share any resources; only classes). Here is the app.gradle for my library project:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.google.code.gson:gson:2.1'
    compile ('libs/eventbus.jar')
    compile project(':core-release')
    compile project(':midware-release')
}

此外,这个程序是一个库项目,它需要另外两个库项目(核心释放,中间件释放),虽然我是能够产生,我可以在我的应用程序使用一个AAR文件,应用程序无法找到依赖库项目类,所以,我不得不在两个库项目添加奥尔斯到我的申请。

Again, this app is a library project which needs two other library projects ('core-release', 'midware-release') and while I was able to generate one AAR file that I can use in my application, the application was unable to find the dependent library projects' classes so, I had to add the two library projects' AARs into my application.

下面是app.gradle应用程序项目(不含人工添加的JAR文件),这是无法找到相关的项目'类:

Here is the app.gradle application project (without adding the JARs manually) which is unable to find the dependent projects' classes:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile files('libs/eventbus.jar')
    compile project(':sdk3-debug')
}

我不认为库项目的AAR文件在相关项目的拉动(AAR或JAR),因此应用程序无法找到类。

I don't think the library project's AAR file is pulling in the dependent projects (AAR or JAR) and hence the application is unable to find the classes.

我读到传递依赖,但我无法找到一个示例实现这可能与我的情况有所帮助。

I read about transitive dependency, but I was unable to find an example implementation which may help with my situation.

推荐答案

这应该解决您的问题:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile files('libs/eventbus.jar')
    compile project(':sdk3-debug') { transitive = true }
}

包含在传递标志真正

这篇关于创建具有多个奥尔斯/ JAR文件的AAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆