程序类型已存在:android.support.v4.media.MediaBrowserCompat$CustomAc

Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback(程序类型已存在:android.support.v4.media.MediaBrowserCompat$CustomActionCallback)
本文介绍了程序类型已存在:android.support.v4.media.MediaBrowserCompat$CustomActionCallback的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我对 Android 开发完全陌生,似乎无法解决此错误:错误:程序类型已存在:android.support.v4.media.MediaBrowserCompat$CustomActionCallback"

I completely new to Android Development and can't seem to resolve this error: "Error: Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback"

这是我的依赖:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
implementation "android.arch.navigation:navigation-fragment:1.0.0-alpha01"
implementation "android.arch.navigation:navigation-ui:1.0.0-alpha01"


androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
testImplementation 'junit:junit:4.12'
}

我在 Google 上搜索了一些内容,最后在开发者页面上找到了有关解决重复的类错误"的信息,但我仍然无法解决这个问题.非常感谢您的帮助!

I've googled some and ended up on the developer page about "Resolve duplicate class errors", but I'm still not able to fix this. Help would be very much appriciated!

推荐答案

选项1

以下对我有用在 gradle.properties 文件中添加以下内容

Following worked for me Add the following in your gradle.properties file

android.useAndroidX = true
android.enableJetifier = false

选项 2(如果上述方法不起作用)

Option 2 (if above does't work)

  1. Android 工作室 -> 导航 ->
  2. 检查是否包含非项目类
  3. 复制完整的类路径 android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat
  4. 查看它的用途.您可能需要删除其中之一.

选项 3您可能会包含包含模块的包,因此请使用以下方法排除 support-v4 模块

Option 3 you might be including package which is including modules as well so exclude the support-v4 module with following method

implementation ('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
      exclude group: 'com.android.support', module:'support-v4'
}

您可以从项目存储库中的命令行使用 ./gradlew :YOURPROJECT:dependencies 分析冲突模块.特别检查您的第三方库是否出现com.android.support-":

You can analyze the conflicting modules using ./gradlew :YOURPROJECT:dependencies from a command line in your project repository. Check especially your third party libraries for occurences of "com.android.support-":

然后从这些依赖项中排除冲突的模块,例如:

Then exclude the conflicting modules from these dependencies like:

   implementation ("com.jakewharton:butterknife:8.8.1") {
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'support-annotation'
    exclude group: 'com.android.support', module: 'support-compat'
}

这篇关于程序类型已存在:android.support.v4.media.MediaBrowserCompat$CustomActionCallback的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum(Android 发布 APK 因 java.lang.AssertionError 崩溃:在 java.lang.Enum 中不可能)
Finished with Non Zero Exit Value 3(以非零退出值 3 结束)
On gradle:3.0.0 More than one file was found with OS independent path #39;META-INF/ASL2.0#39;(在 gradle:3.0.0 上找到多个文件,其独立于操作系统的路径为“META-INF/ASL2.0)
Android : app loading library at runtime on Lollipop but not IceCreamSandwich(Android:运行时在 Lollipop 上而不是 IceCreamSandwich 上的应用程序加载库)
buildConfigField depending on flavor + buildType(buildConfigField 取决于风味 + buildType)
How do I suppress warnings when compiling an android library with gradle?(使用 gradle 编译 android 库时如何抑制警告?)