gpt4 book ai didi

android - Gradle(android实验插件)忽略一个项目依赖

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:12:50 25 4
gpt4 key购买 nike

我在以下项目结构中使用 Gradle Android Experimental 插件:

Root Project
|-- app
|-- my-library

settings.gradle

include ':my-library', ':app'

build.gradle

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.2.0'
}
}

allprojects {
repositories {
jcenter()
}
}

app/build.gradle

apply plugin: 'com.android.model.application'

model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.0"

defaultConfig.with {
applicationId = "a.bundle.id"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "1.0"
}
}

android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile project(':my-library')
}

我的图书馆/build.gradle

apply plugin: 'com.android.model.library'

model {
android {
compileSdkVersion = 'android-23'
buildToolsVersion = '23.0.1'

defaultConfig.with {
minSdkVersion.apiLevel = 15
}
}

android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.txt')
}
}

android.ndk {
moduleName = "xxx"
CFlags += "-I" + "${project.buildDir}".toString() + "/../src/main/jni/libabecs/include"
CFlags += "-std=gnu99"
}
android.sources {
main {
jni {
source {
srcDir 'src/main/jni/libxxx/src'
}
}
}
}
android.productFlavors {
create("arm") {
ndk.abiFilters += "armeabi"
}
create("arm7") {
ndk.abiFilters += "armeabi-v7a"
}
create("arm8") {
ndk.abiFilters += "arm64-v8a"
}
create("x86") {
ndk.abiFilters += "x86"
}
create("x86-64") {
ndk.abiFilters += "x86_64"
}
create("mips") {
ndk.abiFilters += "mips"
}
create("mips-64") {
ndk.abiFilters += "mips64"
}

create("all")
}
}

库项目构建得非常好。在 Android Studio 中,它不会显示任何错误。然而,当试图用 Gradle 构建这个项目时,它只会尝试构建 app 项目并且实际上会忽略 my-library 依赖项,呈现类未找到错误.

如何解决?

最佳答案

显然这是构建插件中未实现的错误/功能。

我只找到了一个直接链接生成的 aar 的变通方法。

build.gradle (someappname)

repositories {
flatDir {
dirs '../my-library/build/outputs/aar'
}
}

dependencies {
compile project(':my-library')
compile(name:'my-library-{flavour}', ext:'aar')
//the rest
}

关于android - Gradle(android实验插件)忽略一个项目依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32727361/

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