繁体   English   中英

库依赖项不适用于模块

[英]Library dependency not working with module

我正在使用Android Studio。 我有两个模块:应用程序(UI)和库。 分别测试时,它们应按预期进行编译和工作,但是当我尝试在应用程序上使用某些库类时,无法构建项目。 我收到此错误:

失败的Android Studio屏幕截图

错误:程序类型已存在:org.apache.xmlbeans.xml.stream.Location

我的库build.gradle只有几行:

apply plugin: 'java-library'


dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'org.apache.poi:poi:3.17'
implementation 'org.apache.poi:poi-ooxml:3.17'

}

sourceCompatibility = "7"
targetCompatibility = "7"

然后我的应用程序的build.gradle是这个

android {
compileSdkVersion 28
defaultConfig {
    applicationId "skrb.appprueba"
    minSdkVersion 21
    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'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
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.android.support:design:28.0.0'
implementation project(path: ':coreLib')

}

当添加这个( implementation project(path: ':coreLib') ,我得到了错误,并且我不知道如何解决。

我尝试过的事情:

  • 清理和重建项目。
  • multiDexEnabled设置为true

试试这个:

implementation(project(path: ':coreLib')) {
    exclude module: 'poi'
    exclude module: 'poi-ooxml'
}

在这里您可以找到更多信息为什么会发生此错误。

根据错误消息,它应该是:

implementation (project(path: ":coreLib")) {
    exclude group: "org.apache.xmlbeans"
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM