我的项目包括一些图书馆项目。库正在使用一些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文件不包含传递的依赖关系,并没有描述库所使用的依赖关系的POM文件。
这意味着,如果你使用的是导入AAR文件flatDir
回购,你也必须指定项目的依赖关系。
您应该使用Maven存储库(您必须在私有或公共Maven存储库中发布库),不会遇到相同的问题。
在这种情况下,gradle使用pom文件下载依赖项,该文件将包含依赖项列表。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句