Dependency conflict when adding mockwebserver to android project - android

I have two separate android projects where I'm implementing integration tests. I finished adding the integration tests to the first one, and I'm moving to my second project, but I encountered a problem while doing the setup and adding the mockwebserver dependency.
Top level gradle file (same for both apps)
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "http://tokbox.bintray.com/maven" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App gradle file for app 1 (working)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://jitpack.io' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
jcenter()
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myApps.appone"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "0.9"
testInstrumentationRunner "com.myApps.CustomTestRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".dev"
versionNameSuffix '-DEBUG'
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "26.+"
}
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":domain")
implementation project(":data")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
androidTestImplementation("com.squareup.okhttp3:mockwebserver:3.11.0")
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'org.mockito:mockito-core:2.5.0'
androidTestImplementation('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
kaptAndroidTest 'com.google.dagger:dagger-compiler:2.16'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.jakewharton:kotterknife:0.1.0-SNAPSHOT'
implementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.makeramen:roundedimageview:2.2.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.5+'
implementation 'com.google.maps:google-maps-services:0.1.20'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation "io.reactivex.rxjava2:rxandroid:2.1.0"
implementation 'com.android.support:multidex:1.0.3'
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "android.arch.lifecycle:viewmodel:1.1.1"
kapt "android.arch.lifecycle:compiler:1.1.1"
kapt 'com.google.dagger:dagger-compiler:2.16'
kapt "com.google.dagger:dagger-android-processor:2.16"
//testImplementation
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.11'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit:1.0.6'
testImplementation "com.nhaarman:mockito-kotlin:1.5.0"
testImplementation 'android.arch.core:core-testing:1.1.1'
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-invites:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
}
apply plugin: 'com.google.gms.google-services'
App gradle file for app 2 (Error)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: "kotlin-kapt"
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://jitpack.io' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
jcenter()
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myApps.apptwo"
minSdkVersion 17
targetSdkVersion 28
versionCode 22
versionName "2.0.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
versionNameSuffix '-DEBUG'
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
kapt {
generateStubs = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(":domain")
implementation project(":data")
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
androidTestImplementation("com.squareup.okhttp3:mockwebserver:3.11.0")
kaptAndroidTest 'com.google.dagger:dagger-compiler:2.16'
implementation 'com.android.support:cardview-v7:28.0.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'
kapt 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation "io.reactivex.rxjava2:rxandroid:2.1.0"
implementation 'com.jakewharton:kotterknife:0.1.0-SNAPSHOT'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-places:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.maps.android:android-maps-utils:0.5+'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:multidex:1.0.3'
def nav_version = "1.0.0-alpha06"
implementation 'com.android.support:design:28.0.0'
implementation "android.arch.navigation:navigation-fragment-ktx:$nav_version"
// use -ktx for Kotlin
implementation "android.arch.navigation:navigation-ui-ktx:$nav_version" // use -ktx for Kotlin
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "android.arch.lifecycle:viewmodel:1.1.1"
kapt "android.arch.lifecycle:compiler:1.1.1"
kapt 'com.google.dagger:dagger-compiler:2.16'
kapt "com.google.dagger:dagger-android-processor:2.16"
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.7#aar') {
transitive = true
}
}
apply plugin: 'com.google.gms.google-services'
The error that is thrown is this :
Cannot find a version of 'com.squareup.okhttp3:okhttp' that satisfies the version constraints:
Dependency path 'apptwo:app:unspecified' --> 'com.squareup.okhttp3:mockwebserver:3.11.0' --> 'com.squareup.okhttp3:okhttp:3.11.0'
Dependency path 'apptwo:app:unspecified' --> 'com.squareup.picasso:picasso:2.71828' --> 'com.squareup.okhttp3:okhttp:3.10.0'
Dependency path 'apptwo:app:unspecified' --> 'com.squareup.retrofit2:retrofit:2.4.0' --> 'com.squareup.okhttp3:okhttp:3.10.0'
Dependency path 'apptwo:app:unspecified' --> 'apptwo:data:unspecified' --> 'com.squareup.okhttp3:logging-interceptor:3.8.1' --> 'com.squareup.okhttp3:okhttp:3.8.1'
Dependency path 'apptwo:app:unspecified' --> 'com.squareup.retrofit2:adapter-rxjava2:2.4.0' --> 'com.squareup.retrofit2:retrofit:2.4.0' --> 'com.squareup.okhttp3:okhttp:3.10.0'
Constraint path 'apptwo:app:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.10.0' because of the following reason: apptwoDevelopmentDebugRuntimeClasspath uses version 3.10.0
Constraint path 'apptwo:app:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.10.0' because of the following reason: apptwoDevelopmentDebugRuntimeClasspath uses version 3.10.0
Constraint path 'apptwo:app:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.10.0' because of the following reason: apptwoDevelopmentDebugRuntimeClasspath uses version 3.10.0
I ran ./gradlew dependencies, and what I saw was that in app 1, the one that is working, gradle solves the conflict and uses okhttp:3.11.0 for all the child dependencies, while in app 2 gradle is unable to solve the conflict.
The only way that I managed to solve this conflict is to downgrade the dependency declaration of mockwebserver, changing
androidTestImplementation("com.squareup.okhttp3:mockwebserver:3.11.0")
to
androidTestImplementation("com.squareup.okhttp3:mockwebserver:3.10.0")
What is the problem here? Why does it work in one app and not on the other?

The gradle version of MockWebServer and Retrofit both utilize okhhtp. You need to match compatible versions.
The reason why it most likely works in one app but not the other is probably that a valid version is either cached or is required for a different package eg okio.
You will need to either downgrade mockwebserver or update retrofit

Related

Can't connect to Firebase. Could not parse the Android Application Module's Gradle config. Resolve gradle issues and/or resync

I have an issue when I try to connect my app to firebase through android studio I get this:
This is the error I get
This is my build.gradle(project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.5'
}
}
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my build.gradle(app):
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
android {
compileSdkVersion 32
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.simcoder.uber"
minSdkVersion 21
//noinspection OldTargetApi
targetSdkVersion 32
versionCode 1
versionName "2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
useLibrary 'org.apache.http.legacy'
manifestPlaceholders = [onesignal_app_id : 'onesignal_app_id',
onesignal_google_project_number: 'REMOTE']
}
buildTypes {
release {
multiDexKeepFile file('multidex-config.txt')
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility '1.8'
targetCompatibility '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0-beta02'
implementation 'com.google.firebase:firebase-database:20.0.0'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'com.google.firebase:firebase-storage:20.0.0'
implementation 'com.firebase:geofire-android:3.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.facebook.android:facebook-login:8.1.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.stripe:stripe-android:16.1.1'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.akexorcist:googledirectionlibrary:1.1.1'
implementation 'com.onesignal:OneSignal:3.15.4'
implementation 'com.google.android.libraries.places:places:2.4.0'
implementation "com.github.addisonelliott:SegmentedButton:3.1.5"
implementation 'com.paypal.sdk:paypal-android-sdk:2.16.0'
implementation 'com.google.android.libraries.places:places:2.4.0'
implementation 'com.github.rtchagas:pingplacepicker:1.1.2'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
implementation 'androidx.multidex:multidex:2.0.1'
/* Needed for RxAndroid */
implementation 'io.reactivex:rxandroid:1.2.1'
implementation 'io.reactivex:rxjava:1.3.8'
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
/* Needed for Rx Bindings on views */
implementation 'com.jakewharton.rxbinding:rxbinding:1.0.1'
annotationProcessor 'com.jakewharton:butterknife:10.2.3'
implementation 'com.squareup.retrofit2:retrofit:2.9.0' //Proguard
implementation 'com.squareup.retrofit2:converter-gson:2.9.0' //Proguard
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' //Proguard
/* Used for server calls */
implementation 'com.squareup.okio:okio:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
/* Used to make Retrofit easier and GSON & Rx-compatible*/
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
/* Used to debug your Retrofit connections */
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation "com.yuyakaido.android:card-stack-view:2.3.4"
implementation 'com.lorentzos.swipecards:library:1.0.9'
implementation 'com.mikhaellopez:circularprogressbar:3.0.3'
implementation 'com.github.tintinscorpion:Dual-color-Polyline-Animation:1.0'
implementation 'com.shreyaspatil:MaterialDialog:2.1'
// Material Design Library
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.ncorti:slidetoact:0.7.0'
testImplementation 'junit:junit:4.13.2'
}
apply plugin: 'com.google.gms.google-services'
Tried a couple of things I found on stackoverflow (removing jcenter and such) and nothing worked out for me. If anyone has any idea how I could solve this issue please let me know.

dependencies gradle android studio

good evening, i am starting in android but the projects that I have downloaded to base myself on most of them throw me errors in the grandle does anyone know why I get error in almost all dependencies? already try to "update" them to their latest version in the gradle file, the project download it from git hub.
build. gradle (Proyect)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.bigohealth"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-firestore:17.1.2'
//implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
//androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
def lifecycle_version = "2.0.0"
def room_version = "2.2.0-alpha02"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.github.christophesmfvvFet:android_maskable_layout:v1.3.1'
implementation 'com trrf r.squareup.retrofit2:adapter-rxjava2:2.6.0'
implementation 'de. , tk./;cx v/8.c8x8hdodenhof:circleimageview:3.1.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
implementation 'com.squareup.retrofit2:converter-scalars:2.6.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.bumptech.glide:glide:4.9.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
implementation 'com.google.firebase:firebase-messaging:20.3.0'
implementation 'com.android.volley:volley:1.1.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation platform('com.google.firebase:firebase-bom:25.12.0')
implementation 'com.google.firebase:firebase-analytics'
}
apply plugin: 'com.google.gms.google-services'
Can you check, if you are under proxy and your android studio is able to connect to internet? Go to file>settings>type 'proxy' > in proxy settings there is a check connection button which will test if android studio is able to connect.
if there is a proxy, then provide the details and check again.
also make sure you do not have offline mode in your gradle settings turned on. Refer following screenshot:
Also your build tools are 4.0.1. Hope you should have the latest android studio too..

Kotlin the compiler warning and application cannot be executed

I have a project using androidx and kotlin, I get an error message when running the application as follows:
w: JAR runtime files in the classpath should have the same version. These files were found in the classpath:
w: /Users/arjava/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.2.31/98678431965f7487d6dc9b399e59b6c4b3921073/kotlin-stdlib-jre7-1.2.31.jar: kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead
and one more message directed me to the directory :
.gradle / caches / modules-2 / files-2.1 / org directory. Jetbrains.kotlin / kotlin-stdlib-jre7 / and xxxxxxx
I'm really confused about this problem, even though I don't apply jre in my app.gradle, I try to delete the files and then there will be more and more.
this is my app.gradle file :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.mhdfdl41.android.gotoclinic"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
androidTestImplementation "android.arch.core:core-testing:1.1.1"
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.smarteist:autoimageslider:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.smarteist:autoimageslider:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.github.humazed:RoomAsset:1.0.3'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.basgeekball:awesome-validation:1.3'
// AAC (Room, Live Data, View Model)
implementation "android.arch.persistence.room:runtime:1.1.1"
kapt "android.arch.persistence.room:compiler:1.1.1"
kapt "android.arch.lifecycle:compiler:1.1.1"
// ViewModel and LiveData
androidTestImplementation "android.arch.persistence.room:testing:1.1.1"
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
//room asset access databases
implementation 'com.github.humazed:RoomAsset:1.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation "androidx.test.ext:junit:1.1.0"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
// implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
//anko
implementation "org.jetbrains.anko:anko:$anko_version"
}
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
repositories{
mavenCentral()
}
what made this happen?
This is how the root project's build.gradle should look alike. when I add kotlin-stdlib-jdk7, it still complains about a version mismatch; only kotlin-stdlib (without the postfix) works for me.
buildscript {
ext.kotlinVersion = "1.3.30"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.4.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
}
}
plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.30"
}
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}"
}
...

Updating com.android.support libraries v7:26.+ to v7:28.0.0 throw Multiple dex files define Lcom/google/common/util/concurrent/ListenableFuture

I am trying to upgrade dependencies from v:7:26.+ to v:7.28.0.0, sync is okay, but Multiple dex error is thrown when I try to run the app, i am not sure what it is complaining, tried to update the multidex dependency from 1.0.1 to 1.0.3 as well but doesn't help. Please help!
Error: Multiple dex files define
Lcom/google/common/util/concurrent/ListenableFuture;
My App Gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp.findme"
minSdkVersion 21
targetSdkVersion 28
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'
}
}
buildToolsVersion '28.0.3'
// Temporary fix until alpha10
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
//implementation 'com.google.android.material:material:1.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
//implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
//implementation 'com.android.support:design:26.+'
//implementation 'com.android.support:cardview-v7:26.+'
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'
/**
* https://github.com/JakeWharton/butterknife
* Avoid findViewById calls by using #BindView on field
* note: cannot go to 10.10.0, require min sdk 26
*/
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//implementation 'com.android.support:multidex:1.0.1'
implementation 'com.android.support:multidex:1.0.3'
// for firebase and firestore
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-firestore:17.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
// for LinkedIn
compile project(path: ':linkedin-sdk')
// for facebook
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.code.gson:gson:2.8.2'
// for BLE
//implementation 'org.altbeacon:android-beacon-library:2.15+'
//implementation 'org.altbeacon:android-beacon-library:2.15.2'
compile(name: 'android-beacon-library-more-reliable-service-stop2-1-g7dbb6b3', ext: 'aar')
// life cycle
implementation 'android.arch.lifecycle:extensions:1.0.0'
annotationProcessor "android.arch.lifecycle:compiler:1.0.0"
// *** Jetpack ***
//
// Release note https://developer.android.com/jetpack/docs/release-notes
// for ROOM
implementation 'com.amitshekhar.android:debug-db:1.0.4'
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
// for work manager
def work_version = "1.0.0-alpha09"
implementation "android.arch.work:work-runtime:$work_version"
// *** End of JackPack ***
// for google play service (location)
implementation 'com.google.android.gms:play-services-location:15.0.1'
// for google login
implementation 'com.google.android.gms:play-services-auth:15.0.1'
// for fire storage
implementation 'com.google.firebase:firebase-storage:16.0.1'
// for image
//implementation 'com.android.support:exifinterface:27.1.1'
implementation 'com.android.support:exifinterface:28+'
// for crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
// for bugfender
implementation 'com.bugfender.sdk:android:1.+'
// userful method
implementation 'org.apache.commons:commons-lang3:3.4'
}
apply plugin: 'com.google.gms.google-services'
My project gradle
buildscript {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
maven {
// for crashlytics
url 'https://maven.fabric.io/public'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
//classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// for crashlytics
classpath 'io.fabric.tools:gradle:1.25.4'
}
}
allprojects {
repositories {
google()
jcenter()
// for crashlytics
maven {
url 'https://maven.google.com/'
}
flatDir {
dirs 'src/main/libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Solution: Excluding Guava group with listenablefuture module from current transitive dependency
implementation("android.arch.work:work-runtime:1.0.0-alpha09") {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
Also, use this configuration for linkedin-sdk:
api project(path: ':linkedin-sdk') {
transitive = true
}
Reason:
As per Google Issue Tracker,
It is surprisingly done on purpose! (reference) Yet new release of Guava will be available soon, with of course resolve issue. For now, excluding as stated above should work perfectly.

Android Program type already present: BufferOverflowException

I developed an Android application on Android Studio 3.2.1 and I imported aar module to read UAE Id cards, I can run the application on my device without any problem.
I tried to generate an APK (debug/signed) file for my application but I get this error:
Program type already present: com.acs.smartcard.BufferOverflowException
where com.acs.smartcard is the module package name.
My app build.gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "biz.wasel.driver"
minSdkVersion 17
targetSdkVersion 28
versionCode 3
versionName "1.0.4"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.code.gson:gson:2.8.4'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
implementation 'me.philio:pinentryview:1.0.6'
implementation 'com.poovam:pin-edittext-field:1.0.3'
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.daimajia.easing:library:2.0#aar'
implementation 'com.daimajia.androidanimations:library:2.3#aar'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.ramotion.cardslider:card-slider:0.2.0'
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
implementation 'com.yarolegovich:discrete-scrollview:1.4.7'
implementation 'net.gotev:uploadservice:3.4.2'
implementation 'com.github.esafirm.android-image-picker:imagepicker:1.13.1'
implementation 'android.arch.paging:runtime:1.0.0'
implementation 'com.github.ome450901:SimpleRatingBar:1.4.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.gmazzo:nestedscroll-maps:0.4'
implementation 'com.hanks.animatecheckbox:library:0.1'
implementation 'com.sothree.slidinguppanel:library:3.4.0'
implementation 'com.hbb20:ccp:2.1.2'
implementation 'com.github.Binary-Finery:Bungee:master-SNAPSHOT'
implementation 'com.github.gcacace:signature-pad:1.2.1'
implementation 'com.facebook.shimmer:shimmer:0.1.0#aar'
implementation project(':acs-plugin-release')
implementation project(':EIDAToolkit')
}
apply plugin: 'com.google.gms.google-services'
and my project level build.gradle is
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'http://maven.microblink.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Note:
When I commented
implementation project(':acs-plugin-release')
form app build.gradle I can generate APK without any problem, but I need this module to finish the app.
I tried a lot of solutions from here and here, but they didn't work!
Any help, please ?!
Thank you

Categories

Resources