Android构建错误:程序类型已存在:android.support.v7.app.** [英] Android build error: Program type already present: android.support.v7.app.**

查看:194
本文介绍了Android构建错误:程序类型已存在:android.support.v7.app.**的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多这样的问题,但是似乎没有一个问题可以解决我的问题,所以也许它更特定于错误消息中列出的库.我已经尝试了其他所有建议的答案,但仍然看到相同的错误.

There are quite a few questions like this, but none of them seem to solve my issue, so maybe it's more specific to the library listed in the error message. I have tried just about everything other answers have suggested, but still see the same error.

我也收到运行任务错误,但我具有 multiDexEnabled true .

I also get a Run Tasks error but I have multiDexEnabled true.

起因:com.android.builder.dexing.DexArchiveMergerException:合并dex存档时出错:

Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:

程序类型已存在:android.support.v7.app.ActionBar $ LayoutParams

消息{种类=错误,文本=程序类型已存在:android.support.v7.app.ActionBar $ LayoutParams,来源= [未知源文件],工具名称= Optional.of(D8)}

Message{kind=ERROR, text=Program type already present: android.support.v7.app.ActionBar$LayoutParams, sources=[Unknown source file], tool name=Optional.of(D8)}

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')

    //noinspection GradleCompatible
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'

    implementation project(':libs:DobSliding')

    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.soundcloud.android:android-crop:1.0.1@aar'
    implementation 'de.halfbit:pinned-section-listview:1.0.0'
    implementation 'com.mikhaellopez:circularimageview:3.2.0'
    implementation 'com.stripe:stripe-android:8.0.0'

    implementation 'com.google.android.gms:play-services:12.0.1'

    //noinspection GradleCompatible
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.1.0'
            }
        } else if (requested.group == "com.google.android.gms") {
            details.useVersion '11.8.0'
        } else if (requested.group == "com.google.firebase") {
            details.useVersion '11.8.0'
        }
    }
}

实施项目(':libs:DobSliding')

我这里只有1个依赖项,所以我想知道这是否引起冲突.

implementation project(':libs:DobSliding')

I only have 1 dependency here, so I am wondering if this is causing conflicts.

dependencies {
    implementation 'com.nineoldandroids:library:2.4.0'
}

./gradlew app:依赖项

不确定如何解释此输出: https://gist.github.com/WrightsCS/8888da5725357d62009773cee09997f0

推荐答案

结果我将一些 .jar 文件复制到了 libs 文件夹中,Android Studio正在使用它们并给我错误.一旦删除了有问题的库(例如AppCompat.jar和classes.jar),构建就很好了.

Turns out I had copied some .jar files into a libs folder and Android Studio was using them and giving me the error. Once I removed the offending libraries, such as AppCompat.jar and classes.jar, the build was fine.

这篇关于Android构建错误:程序类型已存在:android.support.v7.app.**的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆