簡體   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