Android Studio构建错误重复条目

时间:2017-12-06 08:51:26

标签: java android android-gradle build.gradle

我尝试构建APK,但我收到了错误消息。

  

错误:任务':app:transformClassesWithJarMergingForDebug'执行失败。   com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android / support / constraint / ConstraintLayout.class

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.pc.gozlukdenemexxx"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。在ConstraintLayout.java文件中,我删除了这个方法:

class ConstraintLayout extends View {
    public ConstraintLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

但我想知道,删除此方法会导致更多问题吗?