【问题标题】:Android build error: Program type already present: android.support.v7.app.**Android 构建错误:程序类型已存在:android.support.v7.app.**
【发布时间】:2018-08-17 20:13:41
【问题描述】:

这样的问题很多,但似乎都没有解决我的问题,所以也许它更具体到错误消息中列出的库。我几乎尝试了其他答案所建议的所有内容,但仍然看到相同的错误。

我也收到 Run Tasks 错误,但我有 multiDexEnabled true

原因:com.android.builder.dexing.DexArchiveMergerException: 合并 dex 档案时出错:

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

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

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:dependencies

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

【问题讨论】:

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


    【解决方案1】:

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

    检查所有 libs 文件夹,确保您没有携带任何可能从 IntelliJ 项目捆绑的 android 库。

    【讨论】:

      猜你喜欢
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-17
      • 1970-01-01
      • 2018-06-29
      • 1970-01-01
      相关资源
      最近更新 更多