Тип программы уже присутствует: android.support.v4.os.ResultReceiver $ MyResultReceiver

Я рефакторинг приложения для использования androidx. Я изо всех сил старался избавиться от всех библиотек, которые его не поддерживают. Я думал, что я удалил все библиотеки, которые используют библиотеки поддержки, но похоже, что все еще есть что-то, что его импортирует. Теперь я получаю сообщение об ошибке:

AGPBI: {"kind": "error", "text": "Тип программы уже присутствует: android.support.v4.os.ResultReceiver $ MyResultReceiver", "sources": [{}], "tool": "D8" } java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Ошибка при слиянии архивов dex: /Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/532,/Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/0.jar,/Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/1.jar,

...

/Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/530.jar,/Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/531.jar Узнайте, как разрешить введите https://developer.android.com/studio/build/dependencies#duplicate_classes. Тип программы уже присутствует: android.support.v4.os.ResultReceiver $ MyResultReceiver at sun.reflect.GeneratedConstructorAccessor377.newInstance (Неизвестный источник) на sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) в java.lang.reflect. Constructor.newInstance(Constructor.java:423) в java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593) в java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)... в org. gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46) в java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) в java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java: 617) at org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) в java.lang.Thread.run(Thread.java:745) Узнайте, как решить проблему на https://developer.android.com/studio/build/dependencies#duplicate_classes , Тип программы уже присутствует: android.support.v4.os.ResultReceiver $ MyResultReceiver в java.util.concurrent.ForkJoinTask $ AdaptedCallable.exec(ForkJoinTask.java:1431) в java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java: 289) в java.util.concurrent.ForkJoinPool $ WorkQueue.runTask(ForkJoinPool.java:1056) в java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) в java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java: 157) Узнайте, как решить проблему на странице https://developer.android.com/studio/build/dependencies#duplicate_classes. Тип программы уже присутствует: android.support.v4.os.ResultReceiver $ MyResultReceiver at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:129) в com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger. java: 114) в com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:101) в com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:36) на java.util.concurrent.ForkJoinTask $ AdaptedCallable.exec(ForkJoinTask.java:1424)... еще 4 на com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:71) на com.android. tools.r8.utils.ExceptionUtils.withD8CompilationHandler (ExceptionUtils.java:41) в com.android.tools.r8.D8.run(D8.java:89) в com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger. java: 112)... еще 7 на com.android.tools.r8.utils.Reporter.failIfPendingErrors(R eporter.java:83) в com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:62) в com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:62).. 10: app: transformDexArchiveWithDexMergerForDebug FAILED FAILURE: Сбой сборки с исключением. * Что пошло не так: Execution failed for task ': app: transformDexArchiveWithDexMergerForDebug'.

com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: ошибка при слиянии архивов dex: /Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/532,/Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/0.jar,/Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/1.jar,

...

/Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/530.jar,/Users/name/myproject/app/build/intermediates/transforms/dexBuilder/debug/531.jar Узнайте, как разрешить введите https://developer.android.com/studio/build/dependencies#duplicate_classes. Тип программы уже присутствует: android.support.v4.os.ResultReceiver $ MyResultReceiver

Запуск ./gradlew androidDependencies и я получаю:

debugCompileClasspath - Dependencies for compilation
+--- io.realm:realm-android-library:[email protected]
+--- io.realm:realm-android-kotlin-extensions:[email protected]
+--- io.realm:realm-annotations:[email protected]
+--- javax.annotation:jsr250-api:[email protected]
+--- com.google.dagger:dagger-android:[email protected]
+--- androidx.preference:preference:[email protected]
+--- com.google.android.material:material:[email protected]
+--- androidx.appcompat:appcompat:[email protected]
+--- androidx.cardview:cardview:[email protected]
+--- androidx.recyclerview:recyclerview:[email protected]
+--- androidx.gridlayout:gridlayout:[email protected]
+--- androidx.legacy:legacy-support-v4:[email protected]
+--- androidx.vectordrawable:vectordrawable-animated:[email protected]
+--- androidx.vectordrawable:vectordrawable:[email protected]
+--- androidx.palette:palette:[email protected]
+--- com.firebaseui:firebase-ui-auth:[email protected]
+--- com.google.firebase:firebase-auth:[email protected]
+--- com.google.firebase:firebase-config:[email protected]
+--- com.google.firebase:firebase-database:[email protected]
+--- com.jakewharton.rxbinding2:rxbinding:[email protected]
+--- com.jakewharton.rxrelay2:rxrelay:[email protected]
+--- joda-time:joda-time:[email protected]
+--- com.jakewharton.timber:timber:[email protected]
+--- com.uncopt:android.justified:[email protected]
+--- androidx.lifecycle:lifecycle-common-java8:[email protected]
+--- androidx.lifecycle:lifecycle-extensions:[email protected]
+--- androidx.lifecycle:lifecycle-reactivestreams:[email protected]
+--- com.squareup.retrofit2:adapter-rxjava2:[email protected]
+--- com.squareup.retrofit2:converter-moshi:[email protected]
+--- com.squareup.retrofit2:converter-scalars:[email protected]
+--- com.squareup.retrofit2:retrofit:[email protected]
+--- com.squareup.okhttp3:okhttp-urlconnection:[email protected]
+--- com.squareup.okhttp3:logging-interceptor:[email protected]
+--- com.github.franmontiel:PersistentCookieJar:[email protected]
+--- com.squareup.okhttp3:okhttp:[email protected]
+--- com.squareup.moshi:moshi-kotlin:[email protected]
+--- com.github.MFlisar:RxBus2:[email protected]
+--- com.jakewharton:butterknife:[email protected]
+--- com.squareup.leakcanary:leakcanary-android:[email protected]
+--- com.crashlytics.sdk.android:crashlytics:[email protected]
+--- com.f2prateek.rx.preferences2:rx-preferences:[email protected]
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:[email protected]
+--- org.jetbrains.kotlin:kotlin-android-extensions-runtime:[email protected]
+--- com.google.code.findbugs:jsr305:[email protected]
+--- com.getkeepsafe.relinker:relinker:[email protected]
+--- com.google.dagger:dagger:[email protected]
+--- com.android.support:customtabs:[email protected]
+--- com.android.support:cardview-v7:[email protected]
+--- com.jakewharton:butterknife-annotations:[email protected]
+--- com.android.support:design:[email protected]
+--- com.android.support:appcompat-v7:[email protected]
+--- com.android.support:recyclerview-v7:[email protected]
+--- com.android.support:transition:[email protected]
+--- com.google.firebase:firebase-abt:[email protected]
+--- com.google.firebase:firebase-database-connection:[email protected]
+--- com.google.firebase:firebase-analytics:[email protected]
+--- com.google.firebase:firebase-analytics-impl:[email protected]
+--- com.google.firebase:firebase-iid:[email protected]
+--- com.google.firebase:firebase-common:[email protected]
+--- com.google.android.gms:play-services-phenotype:[email protected]
+--- com.google.firebase:firebase-database-collection:[email protected]
+--- com.google.android.gms:play-services-auth:[email protected]
+--- com.google.android.gms:play-services-ads-identifier:[email protected]
+--- com.google.android.gms:play-services-stats:[email protected]
+--- com.google.firebase:firebase-iid-interop:[email protected]
+--- com.google.android.gms:play-services-auth-api-phone:[email protected]
+--- com.google.android.gms:play-services-auth-base:[email protected]
+--- com.google.android.gms:play-services-flags:[email protected]
+--- com.google.android.gms:play-services-base:[email protected]
+--- com.google.android.gms:play-services-tasks:[email protected]
+--- com.google.android.gms:play-services-basement:[email protected]
+--- com.android.support:support-v4:[email protected]
+--- com.android.support:support-media-compat:[email protected]
+--- com.android.support:support-fragment:[email protected]
+--- com.android.support:support-core-utils:[email protected]
+--- com.android.support:animated-vector-drawable:[email protected]
+--- com.android.support:support-core-ui:[email protected]
+--- com.android.support:support-vector-drawable:[email protected]
+--- com.android.support:support-compat:[email protected]
+--- com.android.support:support-annotations:[email protected]
+--- javax.inject:javax.inject:[email protected]
+--- androidx.fragment:fragment:[email protected]
+--- androidx.legacy:legacy-support-core-ui:[email protected]
+--- androidx.legacy:legacy-support-core-utils:[email protected]
+--- androidx.media:media:[email protected]
+--- androidx.transition:transition:[email protected]
+--- androidx.loader:loader:[email protected]
+--- androidx.viewpager:viewpager:[email protected]
+--- androidx.coordinatorlayout:coordinatorlayout:[email protected]
+--- androidx.drawerlayout:drawerlayout:[email protected]
+--- androidx.slidingpanelayout:slidingpanelayout:[email protected]
+--- androidx.customview:customview:[email protected]
+--- androidx.swiperefreshlayout:swiperefreshlayout:[email protected]
+--- androidx.asynclayoutinflater:asynclayoutinflater:[email protected]
+--- androidx.core:core:[email protected]
+--- androidx.collection:collection:[email protected]
+--- androidx.cursoradapter:cursoradapter:[email protected]
+--- androidx.lifecycle:lifecycle-process:[email protected]
+--- androidx.lifecycle:lifecycle-service:[email protected]
+--- androidx.lifecycle:lifecycle-runtime:[email protected]
+--- androidx.lifecycle:lifecycle-livedata:[email protected]
+--- androidx.lifecycle:lifecycle-livedata-core:[email protected]
+--- androidx.lifecycle:lifecycle-common:[email protected]
+--- androidx.arch.core:core-runtime:[email protected]
+--- androidx.arch.core:core-common:[email protected]
+--- androidx.lifecycle:lifecycle-viewmodel:[email protected]
+--- androidx.documentfile:documentfile:[email protected]
+--- androidx.localbroadcastmanager:localbroadcastmanager:[email protected]
+--- androidx.print:print:[email protected]
+--- androidx.interpolator:interpolator:[email protected]
+--- androidx.annotation:annotation:[email protected]
+--- com.android.support.constraint:constraint-layout:[email protected]
+--- com.github.akarnokd:rxjava2-extensions:[email protected]
+--- io.reactivex.rxjava2:rxandroid:[email protected]
+--- io.reactivex.rxjava2:rxjava:[email protected]
+--- org.reactivestreams:reactive-streams:[email protected]
+--- com.squareup.moshi:moshi:[email protected]
+--- org.jetbrains.kotlin:kotlin-reflect:[email protected]
+--- org.jetbrains.kotlin:kotlin-stdlib:[email protected]
+--- com.squareup.leakcanary:leakcanary-analyzer:[email protected]
+--- com.crashlytics.sdk.android:beta:[email protected]
+--- com.crashlytics.sdk.android:crashlytics-core:[email protected]
+--- com.crashlytics.sdk.android:answers:[email protected]
+--- io.fabric.sdk.android:fabric:[email protected]
+--- com.google.android.gms:play-services-measurement-base:[email protected]
+--- com.android.support.constraint:constraint-layout-solver:[email protected]
+--- com.google.android.gms:play-services-auth-license:[email protected]
+--- com.squareup.haha:haha:[email protected]
+--- com.squareup.leakcanary:leakcanary-watcher:[email protected]
+--- com.google.android.gms:play-services-auth-api-phone-license:[email protected]
+--- com.google.android.gms:play-services-auth-base-license:[email protected]
+--- com.squareup.okio:okio:[email protected]
+--- org.jetbrains:annotations:[email protected]
+--- android.arch.lifecycle:runtime:[email protected]
+--- android.arch.lifecycle:common:[email protected]
\--- android.arch.core:common:[email protected]

Вопрос в следующем: есть ли способ узнать, какая зависимость импортирует библиотеку поддержки, кроме проверки build.gradle:

  buildscript {
      repositories {
          maven { url 'https://maven.fabric.io/public' }
          mavenCentral()
          google()
      }
      dependencies {
          classpath 'io.fabric.tools:gradle:1.25.4'
      }
  }

  repositories {
      mavenCentral()
      maven { url 'https://maven.fabric.io/public' }
      maven { url 'https://maven.google.com' }
  }

  apply plugin: 'com.android.application'
  apply plugin: 'kotlin-android'
  apply plugin: 'kotlin-android-extensions'
  apply plugin: 'kotlin-kapt'
  apply plugin: 'io.fabric'
  apply plugin: 'realm-android'

  android {
      def versionMajor = 0
      def versionMinor = 1
      def versionPatch = 0

      compileSdkVersion 'android-P'
      compileOptions {
          targetCompatibility JavaVersion.VERSION_1_8
          sourceCompatibility JavaVersion.VERSION_1_8
          defaultConfig {
              applicationId "org.appid"
              versionName "${versionMajor}.${versionMinor}.${versionPatch}"
              versionCode versionMajor * 10000
              + versionMinor * 100
              + versionPatch

              minSdkVersion 19
              targetSdkVersion 27

              dexOptions {
                  preDexLibraries = false
                  javaMaxHeapSize "4g"
              }
          }
      }

      buildTypes {
          release {
              debuggable false
              minifyEnabled true
              zipAlignEnabled true
              renderscriptDebuggable false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
              signingConfig signingConfigs.release
              javaCompileOptions.annotationProcessorOptions.arguments['butterknife.debuggable'] = 'false'
              resValue "string", "app_version", "${defaultConfig.versionName}"
          }
          debug {
              versionNameSuffix "_dev"
              resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix}"
              debuggable true
              signingConfig signingConfigs.debug
              minifyEnabled false
          }
      }
  }

  def jsr250_api = '1.0'
  def androidxVersion = '1.0.0-alpha1'
  def lifecycle_runtime = '2.0.0-alpha1'
  def daggerVer = '2.16'
  def rxbinding = '2.0.0'
  def rxbus2 = '0.1'
  def retrofit2 = '2.2.0'
  def okhttp3 = '3.4.1'
  def firebase = '15.0.0'
  def firebase_database = '15.0.1'
  def firebaseConfig = '15.0.2'
  def firebase_ui_auth = '3.1.0'
  def butter_knife = '8.8.1'
  def leak_canary = '1.5.1'
  def persistent_cookie_jar = 'v1.0.1'
  def joda_time = '2.5'
  def timber = '4.3.1'
  def justified_text_view = '1.0'
  def crashlytics = '[email protected]'
  def hamcrestVersion = '1.3'
  def espresso_core = '3.1.0-alpha1'
  def mockitoKotlinVersion       = '1.5.0'
  def mockitoKotlinInlineVersion = '2.13.0' // to allow testing final classes
  def junit = '4.12'

  dependencies {
      kapt "com.google.dagger:dagger-android-processor:$daggerVer"
      implementation "com.google.dagger:dagger-android:$daggerVer"
      kapt "com.google.dagger:dagger-compiler:$daggerVer"

      implementation "androidx.appcompat:appcompat:$androidxVersion"
      implementation "androidx.cardview:cardview:$androidxVersion"
      implementation "androidx.recyclerview:recyclerview:$androidxVersion"
      implementation "androidx.gridlayout:gridlayout:$androidxVersion"
      implementation "androidx.preference:preference:$androidxVersion"
      implementation "androidx.vectordrawable:vectordrawable:$androidxVersion"
      implementation "androidx.palette:palette:$androidxVersion"
      implementation "com.google.android.material:material:$androidxVersion"

      implementation "com.google.firebase:firebase-auth:$firebase"
      implementation "com.google.firebase:firebase-config:$firebaseConfig"
      implementation "com.google.firebase:firebase-database:$firebase_database"
      implementation "com.firebaseui:firebase-ui-auth:$firebase_ui_auth"
      implementation "com.jakewharton.rxbinding2:rxbinding:$rxbinding"
      implementation "com.jakewharton.rxrelay2:rxrelay:$rxbinding"

      implementation "joda-time:joda-time:$joda_time"
      implementation "com.jakewharton.timber:timber:$timber"
      implementation "com.uncopt:android.justified:$justified_text_view"

      implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_runtime"
      kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_runtime"
      implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_runtime"
      testImplementation "androidx.arch.core:core-testing:$lifecycle_runtime"

      //To use LiveData with ReactiveStreams API
      implementation "androidx.lifecycle:lifecycle-reactivestreams:$lifecycle_runtime"
      implementation "com.squareup.retrofit2:retrofit:$retrofit2"
      implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit2"
      implementation "com.squareup.retrofit2:converter-moshi:$retrofit2"
      implementation "com.squareup.retrofit2:converter-scalars:$retrofit2"
      implementation "com.squareup.okhttp3:okhttp:$okhttp3"
      implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttp3"
      implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3"
      implementation "com.github.franmontiel:PersistentCookieJar:$persistent_cookie_jar"
      implementation 'com.squareup.moshi:moshi-kotlin:1.5.0'
      implementation "com.github.MFlisar:RxBus2:$rxbus2"
      kapt "com.jakewharton:butterknife-compiler:$butter_knife"
      implementation "com.jakewharton:butterknife:$butter_knife"
      implementation "com.squareup.leakcanary:leakcanary-android:$leak_canary"
      releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary"
      testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary"
      compileOnly "javax.annotation:jsr250-api:$jsr250_api"
      implementation("com.crashlytics.sdk.android:crashlytics:$crashlytics") {
          transitive = true
      }
      implementation 'com.f2prateek.rx.preferences2:rx-preferences:2.0.0-RC2'
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
      testImplementation "junit:junit:$junit"
      testImplementation "com.nhaarman:mockito-kotlin:$mockitoKotlinVersion"
      testImplementation "org.mockito:mockito-inline:$mockitoKotlinInlineVersion"
      testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
      testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion"
      testImplementation "org.hamcrest:hamcrest-integration:$hamcrestVersion"
      androidTestImplementation("androidx.test.espresso:espresso-core:$espresso_core", {
          exclude group: 'com.android.support', module: 'support-annotations'
      })
  }

  androidExtensions {
      experimental = true
  }

  apply plugin: 'com.google.gms.google-services'

  android.packagingOptions {
      exclude 'LICENSE.txt'
      exclude 'META-INF/LICENSE.txt'
      exclude 'META-INF/NOTICE.txt'
      exclude 'META-INF/rxjava.properties'
  }

  configurations.all {
      resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
  }

Ответ 1

Вы можете использовать ./gradlew tasks --all чтобы узнать, какие задачи у вас есть. Среди них будет что-то вроде yourproject:dependencies, которые вы можете запустить, чтобы получить дерево зависимостей следующим образом:

./gradlew yourproject:dependencies

Ответ 2

У меня очень похожая проблема, и в моем случае решение добавляет в gradle.properties две следующие строки:

android.useAndroidX=true
android.enableJetifier=true

Надеюсь, это поможет.

Ответ 3

Попытайтесь МИГРАТЬ на ANDROIDX по следующему пути в Android Studio:

(Refactor> Migrate to AndroidX...)

Ответ 4

Я получил ту же проблему, добавляя,

dataBinding {
    enabled = true
}

в модуле app.gradle. Моя зависимость от градиента такова:

implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'com.google.android.material:material:1.0.0-alpha3'

Когда я изменился,

implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'

Я мог бы избавиться от ошибки при запуске проекта.

Ответ 5

Я думаю, что проблема связана с конфликтующими зависимостями. В моем случае проблема исчезла, когда я удалил зависимость от androidx.

От:

dependencies { implementation "androidx.work:work-runtime:2.1.0" }

Для того, чтобы: dependencies { implementation "android.arch.work:work-runtime:1.0.1" }

Это может быть невозможно, если вы слишком зависимы от androidx.

Ответ 6

просто зависимость от библиотеки AndroidX.

Пример: app/build.gradle:

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

чтобы:

implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

Чем пересобрать снова, показывает много ошибок. просто закомментируйте эти старые библиотеки. повторно импортировать пакет библиотеки Android x. Пример ниже: enter image description here

enter image description here

enter image description here

enter image description here

Marge AndroidX: https://developer.android.com/jetpack/androidx/migrate

Я надеюсь решить вашу проблему.