Миграция на AndroidX - «Тип программы уже представлен: android.support.v4.media.MediaBrowserCompat - PullRequest
0 голосов
/ 27 сентября 2019

Я нахожусь в процессе миграции на androidX и заблокирован этим исключением.

AGPBI: {"kind":"error","text":"Program type already present: 
android.support.v4.media.MediaBrowserCompat$ConnectionCallback$StubApi21",
"sources":[{}],"tool":"D8"}

Так выглядят зависимости моего приложения,

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.adobe.mobile:adobeMobileLibrary:4.17.2'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.browser:browser:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
    implementation 'androidx.lifecycle:lifecycle-common-java8:2.1.0'
    implementation 'com.jakewharton.timber:timber:4.5.1'
    implementation "com.squareup.retrofit2:retrofit:${retrofitLibraryVersion}"
    implementation "com.squareup.retrofit2:converter-gson:${retrofitLibraryVersion}"
    implementation "com.squareup.retrofit2:adapter-rxjava2:${retrofitLibraryVersion}"
    implementation "com.squareup.okhttp3:logging-interceptor:${okHttpLibraryVersion}"
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'io.reactivex.rxjava2:rxjava:2.1.5'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.github.bumptech.glide:glide:3.8.0'
    implementation "org.bouncycastle:bcprov-jdk15on:${bouncyCastleVersion}"
    implementation 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    implementation 'com.google.dagger:dagger:2.10'
    implementation 'com.airbnb.android:lottie:2.7.0'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
    implementation 'com.airbnb.android:lottie:2.7.0'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation "com.google.firebase:firebase-messaging:17.4.0"
    implementation 'com.scottyab:rootbeer-lib:0.0.7'

    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:2.7.5'
    testImplementation "com.squareup.okhttp3:mockwebserver:${okHttpLibraryVersion}"
    testImplementation 'commons-codec:commons-codec:1.11'
    testImplementation 'pl.pragmatists:JUnitParams:1.1.1'

    androidTestImplementation 'org.apache.commons:commons-lang3:3.5'

    androidTestImplementation('androidx.test:runner:1.1.0') {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestImplementation('androidx.test:rules:1.1.0') {
        exclude group: 'com.android.support', module: 'support-annotations'
    }

    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation('androidx.test.espresso:espresso-intents:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    androidTestImplementation('androidx.test.espresso:espresso-contrib:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.android.support', module: 'design'
        exclude group: 'com.android.support', module: 'recyclerview-v7'
    })
    androidTestImplementation 'org.mockito:mockito-core:2.7.5'
    androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.2.0'
    androidTestImplementation "com.squareup.okhttp3:mockwebserver:${okHttpLibraryVersion}"

}

Я уже пытался исключить этот модуль, как показано ниже,

exclude group: 'com.android.support', module: 'support-media-compat'

Действительно не уверен насчетэто, как исключение, может нарушить функции во время выполнения.

Любые предложения будут оценены.

1 Ответ

0 голосов
/ 30 сентября 2019

1).Первый шаг должен быть, получить граф / дерево зависимостей, используя,

gradlew app:dependencies --scan 

(приложение - это имя модуля в моем случае)

2).затем выясните, какой из них использует уязвимый модуль, в моем случае это support-compat & support-media-compat в firebase-core зависимость

Исключая затронутый модуль, помогает мне скомпилировать, но происходит сбой, так как исключенный модуль используется во время выполнения, так что это не правильно.

3).Хитрость заключается в том, чтобы обновить все зависимости до последней версии.

После перехода на AndroidX , если вы получаете сообщение об ошибке компиляции, запишите это, просто закомментировав этилинии, на самом деле помогает вам скомпилировать, но это не правильный путь.Вам необходимо проверить, перенесена ли уязвимая зависимость в AndroidX или все еще использует библиотеки поддержки.

Вы не сможете многое сделать, если зависимая зависимость еще не перенесена в AndroidX. , если зависимость генерирует код, использующий библиотеки поддержки

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...