程序类型已存在:android.support.v4.app.ActionBarDrawerToggle$Delegate

程序类型已存在:android.support.v4.app.ActionBarDrawerToggle$Delegate,android,Android,请任何人知道如何解决这个问题 当我清理托盘然后重建我的应用程序时,出现错误:- Program type already present: android.support.v4.app.ActionBarDrawerToggle$Delegate 我只是Android开发的新手,我的项目需要一些帮助 build.gradle: apply plugin: 'com.android.application' android { compileSdkVersion 27 buil

请任何人知道如何解决这个问题

当我清理托盘然后重建我的应用程序时,出现错误:-

Program type already present: android.support.v4.app.ActionBarDrawerToggle$Delegate
我只是Android开发的新手,我的项目需要一些帮助

build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.xingo.pirateadventures"
        minSdkVersion 14
        targetSdkVersion 27
        multiDexEnabled true

        ndk {
            moduleName "player_shared"
        }
    }

    dexOptions{

        javaMaxHeapSize "4g"
    }

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

        
    }
    sourceSets.main {
        jni.srcDirs = []// <-- disable automatic ndk-build call
    }
}

dependencies {
    implementation ('com.google.android.gms:play-services:+'){exclude module: 'support-v4'}
    implementation files('libs/dagger-1.2.2.jar')
    implementation files('libs/javax.inject-1.jar')
    implementation files('libs/nineoldandroids-2.4.0.jar')
    implementation files('libs/support-v4-19.0.1.jar')
    implementation ('com.android.support:multidex:1.0.1')
}

我做了托盘搜索,但没有得到任何帮助

使用aar而不是jar。试试这条线

implementation "com.android.support:support-v4:19.0.1"
implementation files('libs/support-v4-19.0.1.jar')
然后拆下这条线

implementation "com.android.support:support-v4:19.0.1"
implementation files('libs/support-v4-19.0.1.jar')

首先使用准确版本的Google Play服务,只指定应用程序使用的特定Google Play服务API。例如,如果使用的是location,则只需要以下依赖项:

implementation 'com.google.android.gms:play-services-location:15.0.1'
阅读更多

Second,使用与
compileSdkVersion
版本相同的Android支持库版本。您正在使用以下命令:

implementation files('libs/support-v4-19.0.1.jar')
implementation 'com.android.support:support-v4:27.1.1'
您需要将其更改为以下内容:

implementation files('libs/support-v4-19.0.1.jar')
implementation 'com.android.support:support-v4:27.1.1'
不要忘记从libs目录中删除
support-v4-19.0.1.jar
文件

最后,您的依赖项应该是这样的:

dependencies {
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation files('libs/dagger-1.2.2.jar')
    implementation files('libs/javax.inject-1.jar')
    implementation files('libs/nineoldandroids-2.4.0.jar')
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:multidex:1.0.1'
}

我通过替换
实现('com.android.support:support-v4:27.1.1')


不要忽略渐变依赖项版本不匹配警告/错误,而不要忽略
实现文件('libs/support-v4-19.0.1.jar')

使用新的依赖项(如果可以)或编写解决策略强制使用应用程序依赖项使用的旧库的更新版本

在我的例子中,版本23的
ActionBarDrawableToggle
存在冲突。。由我使用的依赖项使用
我被迫在整个应用程序中使用版本27.1.1的support-v4忽略嵌入依赖项中的版本

 configurations.all {
        resolutionStrategy {
        force "com.android.support:support-v4:27.1.1"
      }
}

有时,由于一些不必要或未使用的第三方库,会出现此问题

我使用时出错了

implementation 'com.kbeanie:image-chooser-library:1.6.0'
我不得不从依赖项中删除它,我的代码构建成功了