【发布时间】:2016-10-22 12:14:37
【问题描述】:
我的项目包括一些图书馆项目。库正在使用一些 aar 文件,并且它的依赖已在模块中定义:gradle 文件。我在我的项目中包含这个库时遇到了问题。
如果我在 app->lib 中保留重复的 aar 文件并在 app->gradle 文件中定义它们的依赖关系,那么就没有问题。但这不应该是正确的方法。
请在下方查找错误:
配置项目 ':app' 时出现问题。
Could not resolve all dependencies for configuration ':app:_qaDebugCompile'. Could not find :api-release:. Searched in the following locations:
https://jcenter.bintray.com//api-release//api-release-.pom
https://jcenter.bintray.com//api-release//api-release-.aar
file:/D:/sample/sample-android-app/app/libs/api-release-.aar
file:/D:/sample/sample-android-app/app/libs/api-release.aar
Required by:
sample-android-app:app:unspecified > sample-android-app:misnapworkflow:unspecified
请在下面找到项目结构:
sample
|-- app
|-- misnapworkflow
|
|-- lib
|-- api-release.aar
在应用程序的 gradle 文件中提到了包含项目
依赖项 { 编译项目(':misnapworkflow') }
请在下面找到 misnapworkflow gradle 文件:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 23
consumerProguardFiles 'proguard-rules.pro'
}
lintOptions {
abortOnError false
}
// Publish both debug and release libraries
publishNonDefault true
buildTypes {
debug {
debuggable true
jniDebuggable true
minifyEnabled false
shrinkResources false
testCoverageEnabled true
}
release {
signingConfig signingConfigs.debug
debuggable false
jniDebuggable false
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
task grantPermissions(type: Exec, dependsOn: 'installDebugTest') {
logger.warn('Granting permissions...')
commandLine "adb shell pm grant com.miteksystems.misnap.misnapworkflow.test android.permission.WRITE_EXTERNAL_STORAGE".split(' ')
commandLine "adb shell pm grant com.miteksystems.misnap.misnapworkflow.test android.permission.CAMERA".split(' ')
logger.warn('Permissions granted.')
}
tasks.whenTaskAdded { task ->
if (task.name.startsWith('connected')
|| task.name.startsWith('create')) {
task.dependsOn grantPermissions
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
// Add dependency for MiSnap external API
compile(name: 'api-release', ext: 'aar')
// Add dependency for MiSnap
compile(name: 'misnap-release', ext: 'aar') {
exclude module: 'appcompat-v7'
}
// Eventbus dependency
compile 'de.greenrobot:eventbus:2.4.0'
// Add OPTIONAL dependency for Manatee
compile(name: 'manatee-release', ext: 'aar')
compile(name: 'cardio-release', ext: 'aar')
}
repositories {
flatDir {
dirs 'libs'
}
}
【问题讨论】:
-
你解决了这个问题吗?我面临着完全相同的问题。如果我不将 aar 文件复制到应用程序模块中,它就不起作用。我确实在他的应用程序 gradle 中有 jcenter 和 flatDir 指令,但没有区别。
-
@Lancelot 我已经在我的项目中解决了这个问题,请查看下面的答案
-
@aldok 谢谢!!!已经有一段时间了,所以不再需要它了。无论如何谢谢:)
标签: android android-studio gradle android-gradle-plugin aar