Android构建错误:程序类型已存在:android.support.v7.app。**

时间:2018-08-17 20:13:41

标签: android gradle android-gradle android-actionbar android-multidex

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

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

  

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

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

  

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

enter image description here

build.grade

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个依赖项,所以我想知道这是否引起冲突。

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

./ gradlew app:依赖项

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

1 个答案:

答案 0 :(得分:1)

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

检查所有 libs 文件夹,以确保您没有携带任何与IntelliJ项目捆绑在一起的android库。