Not able to add kiteconnect.jar into Android application

RajeshDhalange
RajeshDhalange edited May 2018 in Java client
I am trying to import kiteconnect.jar into the Android application but getting following error

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Tried solutions
1. Enable multidex option


My App Gradle is as follow
apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.stockanalysis"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'android.arch.lifecycle:runtime:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.dagger:dagger:2.4'
annotationProcessor 'com.google.dagger:dagger-compiler:2.4'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
implementation 'joda-time:joda-time:2.9.9'

implementation files('libs/kiteconnect.jar')
compile 'com.android.support:multidex:1.0.1'

implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'

}
Tagged:
  • sujith
    You can refer this.
  • sujith
    sujith edited May 2018
    javakiteconnect doesn't require multiDexEnabled: true. I hope you are doing this because of some other reason.
  • RajeshDhalange
    No @sujith enabling multDexEnable: true is just one of the try to resolve the problem, and your refer link also suggest to do multiDexEnable true but still problem exist
  • RajeshDhalange
    You can reproduce this issue with above gradle configuration.
  • sujith
    You don't need to make any changes to gradle file. You can just create a project include jar file inside the app/libs and then in the app/build.gradle inside the dependencies section add this
    compile files('libs/kiteconnect.jar')
  • RajeshDhalange
    RajeshDhalange edited May 2018
    Tried this solution, it is not working when adding any single other libraries, not even Google's Gson lib.
    Request you to compile kiteconnect lib with any other library like Retrofit and Gson lib.

    check the following new sample
    apply plugin: 'com.android.application'

    android {
    compileSdkVersion 27
    defaultConfig {
    applicationId "com.hourlybee.ksample"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
    release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    }
    }

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    compile files('libs/kiteconnect.jar')

    // implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    // implementation 'com.squareup.retrofit2:converter-scalars:2.4.0'
    // implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.google.code.gson:gson:2.6.2'
    //implementation 'com.squareup.okhttp3:logging-interceptor:3.6.0'
    compile 'com.android.support:support-annotations:27.1.1'
    }
  • sujith
    sujith edited May 2018
    Here is my app/build.gradle file

    apply plugin: 'com.android.application'

    android {

    compileSdkVersion 26
    defaultConfig {
    applicationId "com.zerodha.kiteconnectexample"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
    release {
    minifyEnabled false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    }
    useLibrary 'org.apache.http.legacy'
    }

    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile files('libs/kiteconnect.jar')
    }
  • Dom51
    Hello there,
    Is this issue, had been solved?
Sign In or Register to comment.