首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Dynamsoft Android与okhttp3冲突

Dynamsoft Android与okhttp3冲突
EN

Stack Overflow用户
提问于 2018-09-11 07:51:02
回答 1查看 280关注 0票数 0

我在公司的一个项目中工作,为了文档扫描的目的,我需要集成Dynamsoft Android 。这个问题是,当sdk依赖项添加到当前项目时,它会与okhttp3发生冲突,同时在构建控制台上出现此错误:

**任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.执行失败

合并dex存档时com.android.builder.dexing.DexArchiveMergerException:错误:程序类型已经存在: okhttp3.Address学习如何在classes.**解决问题

正如它在开发人员控制台中所指出的,okhttp3已经被排除在Dynamsoft依赖项之外(实际上以多种方式进行了尝试),但问题仍然存在。

代码语言:javascript
复制
 apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
    buildToolsVersion "28.0.2"
    compileSdkVersion 28
    defaultConfig {
        applicationId "no.aspit.capture"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }

        dev {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
        debug {

        }
    }

    lintOptions {
        abortOnError false
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'okhttp3/internal/publicsuffix/publicsuffixes.gz'
    }
}


kotlin {
    experimental {
        coroutines 'enable'
    }
}

androidExtensions {
    experimental = true
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.cardview:cardview:1.0.0-rc02'
    implementation 'androidx.core:core-ktx:1.0.0-rc02'
    implementation "android.arch.work:work-runtime-ktx:1.0.0-alpha08"
    implementation 'androidx.preference:preference:1.0.0-rc02'
    implementation 'androidx.fragment:fragment-ktx:1.0.0-rc02'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc02'
    implementation 'com.google.android.material:material:1.0.0-rc01'

    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    implementation 'com.squareup.moshi:moshi-kotlin:1.6.0'
    implementation 'com.squareup.retrofit2:converter-moshi:2.4.0'

    kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.6.0'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'


    implementation 'de.hdodenhof:circleimageview:2.2.0'

    implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
    //noinspection GradleCompatible
    implementation "com.android.support:design:26.1.0"
    implementation 'com.squareup.picasso:picasso:2.71828'
    //Joda time
    implementation 'net.danlew:android.joda:2.9.9.4'
    // Image Compression
    implementation 'id.zelory:compressor:2.1.0'

    //Stetho
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'

    //Dynumsoft
    implementation ('com.dynamsoft:dynamsoftcamerasdk:2.0@aar'){
    exclude group: 'com.squareup.okhttp3'
    }


}

repositories {
    maven {
        url "http://download.dynamsoft.com/maven/dcs"
    }
EN

回答 1

Stack Overflow用户

发布于 2018-10-31 01:59:48

您可以尝试按以下方式解决冲突:

代码语言:javascript
复制
configurations.all {
    all*.exclude group: 'com.squareup.okhttp3', module: 'okhttp'
    all*.exclude group: 'com.squareup.okio', module: 'okio'
    resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.10.0'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.cardview:cardview:1.0.0-rc02'
    implementation 'androidx.core:core-ktx:1.0.0-rc02'
    implementation "android.arch.work:work-runtime-ktx:1.0.0-alpha08"
    implementation 'androidx.preference:preference:1.0.0-rc02'
    implementation 'androidx.fragment:fragment-ktx:1.0.0-rc02'

    implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc02'
    implementation 'com.google.android.material:material:1.0.0-rc01'

    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
    implementation 'com.squareup.moshi:moshi-kotlin:1.6.0'
    implementation 'com.squareup.retrofit2:converter-moshi:2.4.0'

    kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.6.0'

    testImplementation 'junit:junit:4.12'

    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'


    implementation 'de.hdodenhof:circleimageview:2.2.0'

    implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
    //noinspection GradleCompatible
    implementation "com.android.support:design:26.1.0"
    implementation 'com.squareup.picasso:picasso:2.71828'
    //Joda time
    implementation 'net.danlew:android.joda:2.9.9.4'
    // Image Compression
    implementation 'id.zelory:compressor:2.1.0'

    //Stetho
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'

    //Dynumsoft
    implementation ('com.dynamsoft:dynamsoftcamerasdk:2.0@aar')
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52271152

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档