gpt4 book ai didi

android-gradle-plugin - 创建具有多个 AAR/JAR 的 AAR

转载 作者:行者123 更新时间:2023-12-03 15:12:34 25 4
gpt4 key购买 nike

我看到了各种开发人员发布的问题(Android Studio combine 2 .aar into one 和其他人),但我还没有看到明确的答复使我能够创建一个包含 1 个或多个 AAR 或 JAR 的 AAR(我可以使用 JAR,因为我没有需要共享任何资源;只有类)。这是我的图书馆项目的 app.gradle:

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')
}

同样,这个应用程序是一个库项目,它需要另外两个库项目('core-release'、'midware-release'),虽然我能够生成一个可以在我的应用程序中使用的 AAR 文件,但该应用程序无法找到依赖库项目的类,所以我不得不将两个库项目的 AAR 添加到我的应用程序中。

这是无法找到依赖项目类的 app.gradle 应用程序项目(不手动添加 JAR):
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),因此应用程序无法找到这些类。

我阅读了传递依赖,但我无法找到可能对我的情况有所帮助的示例实现。

最佳答案

这应该可以解决您的问题:

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 }
}

true 处包含可传递标志.

关于android-gradle-plugin - 创建具有多个 AAR/JAR 的 AAR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34445399/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com