简体   繁体   English

Android Merge libs gradle

[英]Android Merge libs gradle

My gradle file: 我的gradle文件:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1002
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }



}
dependencies {
    api fileTree(include: ['*.jar'], dir: 'libs')
    api 'androidx.appcompat:appcompat:1.0.2'
    api 'androidx.palette:palette:1.0.0'
    api 'androidx.mediarouter:mediarouter:1.0.0'
    api 'androidx.cardview:cardview:1.0.0'
    api 'androidx.legacy:legacy-support-v4:1.0.0'
    api 'androidx.recyclerview:recyclerview:1.0.0'
    api 'androidx.annotation:annotation:1.0.1'
    api 'androidx.percentlayout:percentlayout:1.0.0'
    api "androidx.fragment:fragment:1.1.0-alpha03"
    api 'androidx.preference:preference:1.0.0'



}

On build app, I get next error: 在构建应用程序时,出现下一个错误:

 Task :mobile:transformClassesWithMultidexlistForDebug FAILED
AGPBI: {"kind":"error","text":"Program type already present: com.google.common.util.concurrent.ListenableFuture","sources":[{}],"tool":"D8"}

FAILURE: Build failed with an exception.

 What went wrong:
Execution failed for task ':mobile:transformClassesWithMultidexlistForDebug'.
 com.android.build.api.transform.TransformException: Error while generating the main dex list:
  Error while merging dex archives: 
  Program type already present: com.google.common.util.concurrent.ListenableFuture

I found the error. 我发现了错误。 Error in library incompatibility "androidx.fragment:fragment:1.1.0-alpha03" and 'androidx.appcompat:appcompat:1.0.2' . 库不兼容"androidx.fragment:fragment:1.1.0-alpha03"'androidx.appcompat:appcompat:1.0.2'

How can I fix the error without deleting androidx.fragment dependency? 如何在不删除androidx.fragment依赖关系的情况下解决错误?

UPD. UPD。 Solution: 解:

api 'androidx.appcompat:appcompat:1.1.0-alpha01'
api "androidx.fragment:fragment:1.0.0"

Solution: 解:

Replace: 更换:

api 'androidx.appcompat:appcompat:1.0.2'
api "androidx.fragment:fragment:1.1.0-alpha03"

to: 至:

api 'androidx.appcompat:appcompat:1.1.0-alpha01'
api "androidx.fragment:fragment:1.0.0"

Hopefully, the AndroidX library will become more stable ... 希望AndroidX库将变得更加稳定...

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

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