我整整2天一直在阅读和搜索,但没有成功。我不知道该怎么做,因此决定在这里发布。我正在尝试在正在开发的应用程序中使用我的图书馆项目。这是林间空地文件:
主应用程序项目/app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.proyectodesarrollador.sdktester"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
buildToolsVersion '28.0.2'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//debugImplementation project(':proyectodesarrolladorsdk')
//releaseImplementation project(':proyectodesarrolladorsdk')
//implementation project(':proyectodesarrolladorsdk')
api project(':proyectodesarrolladorsdk')
}
主应用程序项目/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
主应用程序项目/settings.gradle
include ':app'
include ':proyectodesarrolladorsdk'
project(':proyectodesarrolladorsdk').projectDir=new File('/home/notbad/Documents/Projects/Android/proyectodesarrolladorsdk')
Library / app / build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
}
}
buildToolsVersion '28.0.2'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
}
Library / build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Library / settings.gradle
包括':app'
这就是gradle使用gradlew build --debug吐出的东西
4:03:21.088 [DEBUG] [org.gradle.internal.component.model.ComponentAttributeMatcher] No candidates for {com.android.build.api.attributes.BuildTypeAttr=release, com.android.build.gradle.internal.dependency.AndroidTypeAttr=Aar, org.gradle.usage=java-runtime} and fallback null does not match. Select nothing.
14:03:21.089 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Calculate task graph'
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Could not determine the dependencies of task ':app:preReleaseBuild'.
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not resolve project :proyectodesarrolladorsdk.
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Required by:
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] project :app
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Unable to find a matching configuration of project :proyectodesarrolladorsdk: None of the consumable configurations have attributes.
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger]
14:03:21.090 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 0s
14:03:21.091 [DEBUG] [org.gradle.internal.work.DefaultWorkerLeaseService] Worker lease root.1 completed (0 worker(s) in use)
如您所见,我在lib和app(调试,发行版)中仅使用2种配置。两个模块都使用相同的确切名称/配置。如果有人能帮助我,我将非常感激。
P.D。更多数据:如果我通过File-> New-> Import Module导入模块,一切都按预期进行,但是问题是lib项目已复制到app项目中,而这是我所不希望的。我想参考一下。 干杯。