首页 > 解决方案 > Android Studio: Program type already present

问题描述

I'm trying to compile my project in Android Studio and I'm getting this error, I know is because of any dependence is duplicating the support-v4 library but I can't fix it.

Program type already present: android.support.v4.widget.SlidingPaneLayout$PanelSlideListener

Here is my build.gradle. Sliding menu library only depends on support-v4, but I can't remove this dependece as many errors appears then.

apply plugin: 'com.android.application'

buildscript{
    repositories {
        //maven { url "https://maven.google.com" } // Gradle < 4.0

mavenCentral()
             jcenter()
        //google()
    }
    allprojects {
        repositories {
            mavenCentral() // Add following
            jcenter()
        }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:3.1.3"
    }
}

dependencies {

    //implementation fileTree(include: '*.jar', dir: 'libs')
    implementation files('libs/wekaSTRIPPED.jar')
    implementation files('libs/pad.jar')
    implementation files('libs/javacsv.jar')
    implementation files('libs/extras.jar')

  //implementation (group: 'net.sourceforge.javacsv', name: 'javacsv', version: '2.0'){
      //exclude group: 'com.google.android', module: 'support-v4'
    //}
    implementation 'com.android.support:support-compat:27.1.1'
    implementation  'com.android.support:multidex:1.0.0'
    implementation('com.android.support:appcompat-v7:27.1.1'){
        exclude group: 'com.android.support', module: 'appcompat-v4'
    }
    //implementation('com.android.support:design:27.1.1') {
       // exclude group: 'com.android.support'
        //exclude module: 'appcompat-v7'
        //exclude module: 'support-v4'
        //exclude module: 'appcompat-v4'

    //}
    implementation project(':SlidingMenu')
    implementation ('com.google.code.gson:gson:2.2.2'){
        exclude group: 'com.google.android', module: 'support-v4'
        exclude group: 'com.google.android', module: 'appcompat-v4'
       }


    android {
        compileSdkVersion 27
        buildToolsVersion "27.0.3"




          defaultConfig {
        multiDexEnabled true
        }
        configurations.all {

        }
        sourceSets {
            main {
                manifest.srcFile 'AndroidManifest.xml'
                java.srcDirs = ['src']
                resources.srcDirs = ['src']
                aidl.srcDirs = ['src']
                renderscript.srcDirs = ['src']
                res.srcDirs = ['res']
                assets.srcDirs = ['assets']
            }

            // Move the tests to tests/java, tests/res, etc...
            androidTest.setRoot('tests')

            // Move the build types to build-types/<type>
            // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
            // This moves them out of them default location under src/<type>/... which would
            // conflict with src/ being used by the main source set.
            // Adding new build types or product flavors should be accompanied
            // by a similar customization.
            debug.setRoot('build-types/debug')
            release.setRoot('build-types/release')
        }
    }
}

android {
    buildToolsVersion '27.0.3'
}
repositories {
    google()
}

Thank you for all support.

标签: androidandroid-studiogradledependencies

解决方案


推荐阅读