Duplicate classes when building in Android Studio - android

i am getting an error when building an Android Studio project.
Program type already present: com.google.android.gms.internal.measurement.zzdz
here is my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'io.fabric'
apply plugin: 'com.getkeepsafe.dexcount'
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
classpath 'com.google.gms:google-services:3.2.1'
}
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 202
versionName "2.0.0"
buildConfigField "boolean", "CRASHLYTICS_ENABLED", "false"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
flavorDimensions "type", "name"
productFlavors {
magazines {
dimension "type"
}
magazine {
dimension "name"
// Remove next line to enable Crashlytics and change false to true in second line
ext.enableCrashlytics = false
buildConfigField "boolean", "CRASHLYTICS_ENABLED", "false"
}
wind {
dimension "name"
// Remove next line to enable Crashlytics and change false to true in second line
ext.enableCrashlytics = false
buildConfigField "boolean", "CRASHLYTICS_ENABLED", "false"
}
script {
//// Use custom gradle file if it exists in script product flavor folder
if (new File("./main/src/script/custom.gradle").exists()) {
println 'custom.gradle script exists'
apply from: "../main/src/script/custom.gradle";
} else {
throw new GradleException('No custom.gradle script exists')
}
//applicationId scriptApplicationId
dimension "name"
buildConfigField "boolean", "CRASHLYTICS_ENABLED", "true"
}
}
lintOptions {
abortOnError false
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
}
dependencies {
implementation fileTree(include: '*.jar', dir: 'libs')
//added here
implementation fileTree(include: '*.java', dir: 'libs')
implementation fileTree(include: '*.so', dir: 'libs')
//til here
implementation project(':appiraterAndroid')
implementation 'de.greenrobot:eventbus:2.4.0'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'commons-io:commons-io:2.4'
implementation 'io.reactivex:rxandroid:0.24.0'
implementation 'uk.co.chrisjenx:calligraphy:2.1.0'
implementation 'com.github.castorflex.smoothprogressbar:library:1.1.0'
implementation 'com.github.castorflex.smoothprogressbar:library-circular:1.1.0'
implementation 'com.anjlab.android.iab.v3:library:1.0.26#aar'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'net.danlew:android.joda:2.8.1'
implementation('com.crashlytics.sdk.android:crashlytics:2.4.0#aar') {
transitive = true;
}
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-core-utils:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation('com.github.afollestad.material-dialogs:core:0.8.5.5#aar') {
transitive = true
}
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.5'
implementation 'com.google.android.gms:play-services-gcm:16.0.0'
implementation 'com.google.android.gms:play-services-ads:17.1.0'
implementation "com.google.android.gms:play-services-base:16.0.1"
}
apply plugin: 'com.google.gms.google-services'
i am sure that there is something to do with dependencies and versions , but i can't find out.
i tried to clean gradle cache and restarting Android studio , but i am still getting the error above.

Migrate project to androidx support
Click -> Refactor -> Migrate to AndroidX
and update the libraries

Related

android kotlin multiplatform kotlinx.serialization works on debug but does not work on release version

We are making our next project in the company with kotlin multiplatform. Everything worked fine until I tried to create a release version for android to beta test. I got this error in release versions while everything works fine in debug.
[NetworkManager] unknown exception: l.a.w: Can't locate argument-less serializer for class a. For generic classes, such as lists, please provide serializer explicitly.
here this is project level build.gradle
buildscript {
ext.kotlin_version = '1.3.70'
ext.versions = [
"ktor" : "1.3.2",
"serialization" : "0.20.0",
"coroutines" : "1.3.6",
]
repositories {
maven { url 'https://maven.google.com' }
maven { url 'https://dl.google.com/dl/android/maven2' }
maven { url "https://s3-eu-west-1.amazonaws.com/elasticode-sdk/Android/maven/" }
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.3.70' // or any other kotlin plugin
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.70'
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
maven { url "https://s3-eu-west-1.amazonaws.com/elasticode-sdk/Android/maven/" }
google()
jcenter()
}
}
and this is common modules build.gradle
apply plugin: 'kotlin-multiplatform'
apply plugin: 'kotlinx-serialization'
kotlin {
targets {
iosArm64("ios64")
iosX64("iosSim")
configure([
ios64,
iosSim
]) {
binaries.framework {
baseName = 'PassengerCommon'
}
}
fromPreset(presets.jvm, 'android')
}
sourceSets {
commonMain.dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${versions.serialization}"
implementation "io.ktor:ktor-client:${versions.ktor}"
implementation "io.ktor:ktor-client-json:${versions.ktor}"
implementation "io.ktor:ktor-client-serialization:${versions.ktor}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${versions.coroutines}"
}
iosMain {
dependsOn commonMain
iosSimMain.dependsOn(it)
ios64Main.dependsOn(it)
dependencies {
// HTTP
implementation "io.ktor:ktor-client-ios:${versions.ktor}"
implementation "io.ktor:ktor-client-json-native:${versions.ktor}"
implementation "io.ktor:ktor-client-serialization-native:${versions.ktor}"
// Coroutines
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:${versions.coroutines}"
}
}
iosSimMain {
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-iosx64:${versions.serialization}"
}
}
ios64Main {
dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-iosarm64:${versions.serialization}"
}
}
androidMain.dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${versions.serialization}"
implementation "io.ktor:ktor-client-serialization-jvm:${versions.ktor}"
implementation "io.ktor:ktor-client-okhttp:${versions.ktor}"
implementation "com.squareup.okhttp3:logging-interceptor:4.0.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.coroutines}"
}
}
// Create a task building a fat framework.
task debugFatFramework(type: FatFrameworkTask) {
// The fat framework must have the same base name as the initial frameworks.
baseName = 'PassengerCommon'
// The default destination directory is '<build directory>/fat-framework'.
destinationDir = file("$buildDir/fat-framework/debug")
// Specify the frameworks to be merged.
from(
targets.ios64.binaries.getFramework("DEBUG"),
targets.iosSim.binaries.getFramework("DEBUG")
)
}
// Create a task building a fat framework.
task releaseFatFramework(type: FatFrameworkTask) {
// The fat framework must have the same base name as the initial frameworks.
baseName = 'PassengerCommon'
// The default destination directory is '<build directory>/fat-framework'.
destinationDir = file("$buildDir/fat-framework/release")
// Specify the frameworks to be merged.
from(
targets.ios64.binaries.getFramework("RELEASE"),
targets.iosSim.binaries.getFramework("RELEASE")
)
}
}
configurations {
compileClasspath
}
lastly this is the android modules build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlinx-serialization'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.gms.google-services'
repositories {
flatDir {
dirs 'libs'
}
google()
mavenCentral()
}
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 28
defaultConfig {
applicationId "com.lines.passenger"
minSdkVersion 21
targetSdkVersion 28
versionCode 53
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}
signingConfigs {
release {
try {
storeFile file('../keystores/release.jks')
storePassword *****
keyAlias "*****"
keyPassword *****
} catch (Exception ex) {
throw new Exception("You should define KEYSTORE_PASSWORD and KEY_PASSWORD in gradle.properties.")
}
}
debug {
storeFile file('../keystores/debug.keystore')
}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
buildTypes {
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
resValue("string", "app_name", "Passenger")
signingConfig signingConfigs.debug
resValue("string", "g_maps_api_key", "*****")
manifestPlaceholders = [MAPS_API_KEY: "*****"]
resValue "string", "app_version", "${defaultConfig.versionName}"
resValue("string", "PUSHER_APP_KEY", "*****")
resValue("string", "new_relic_key", "*****")
}
release {
resValue "string", "app_version", "${defaultConfig.versionName}"
minifyEnabled true
shrinkResources true
zipAlignEnabled true
resValue("string", "app_name", "Lines")
signingConfig signingConfigs.release
resValue("string", "g_maps_api_key", "*****")
manifestPlaceholders = [MAPS_API_KEY: "*****"]
resValue("string", "PUSHER_APP_KEY", "*****")
resValue("string", "new_relic_key", "*****")
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/*.kotlin_module'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
testImplementation "io.mockk:mockk:1.9"
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
implementation project(':PassengerCommon')
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.firebase:firebase-messaging:20.2.1'
implementation 'com.google.firebase:firebase-core:17.4.3'
implementation 'com.google.firebase:firebase-config:19.1.4'
implementation 'com.google.firebase:firebase-crashlytics:17.1.0'
implementation 'com.google.firebase:firebase-storage:19.1.1'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.maps.android:android-maps-utils:0.4.4'
implementation 'com.afollestad.material-dialogs:core:0.9.5.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
implementation 'com.squareup.retrofit2:retrofit:2.2.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.2.0'
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
implementation 'com.jakewharton:butterknife:10.0.0'
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.5.0")
implementation 'com.karumi:dexter:4.2.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.prolificinteractive:material-calendarview:1.4.3'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'q.rorbin:badgeview:1.1.3'
implementation 'com.jakewharton.rxbinding3:rxbinding:3.0.0-alpha2'
implementation 'info.hoang8f:android-segmented:1.0.6'
implementation 'com.elasticode.sdk:elasticode-android:2.1.1'
implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
implementation 'com.pusher:pusher-websocket-android:0.7.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.coroutines}"
}
apply plugin: 'com.google.gms.google-services'
If you guys need anything I will gladly provide
If the app works in debug but not in release, it's probably because Proguard minified your classes and deserialization no longer works due to different (shorter) class and property names.
Make sure you have this in your proguard:
-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.SerializationKt
-keep,includedescriptorclasses class com.yourcompany.yourpackage.**$$serializer { *; } # <-- change package name to your app's
-keepclassmembers class com.yourcompany.yourpackage.** { # <-- change package name to your app's
*** Companion;
}
-keepclasseswithmembers class com.yourcompany.yourpackage.** { # <-- change package name to your app's
kotlinx.serialization.KSerializer serializer(...);
}
If deserialization still fails, please provide an example of how you are deserializing network response(s) into data classes.

Failed to resolve: com.afollestad:bridge:5.1.2

I have Android Studio 3.2.1 and i having an issue syncing my project.
Error:
Failed to resolve: com.afollestad:bridge:5.1.2
Show in File
Show in Project Structure dialog
UPDATED:
the error also persists with android studio 3.4
And my gradles files are:
App:
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 {
lintOptions {
checkReleaseBuilds false
// abortOnError false
}
signingConfigs {
Signing_Release {
keyAlias project.keyAlias
keyPassword project.keyPassword
storeFile file(project.storeFile)
storePassword project.storePassword
}
}
compileSdkVersion 28
defaultConfig {
applicationId "XXXXXXXXXXXXXXXXXXXXXXXX"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "3.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
productFlavors {
app1 {
applicationId 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
buildConfigField "String", "URL_BASE", "https://XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
versionCode 16
flavorDimensions "default"
signingConfig signingConfigs.Signing_Release
}
app2 {
applicationId 'com.assertsoft.assertforms.centenarioseguridad'
buildConfigField "String", "URL_BASE", "\"https://centenarioseguridad.onfieldsystem.cl/rest/\""
versionCode 1
flavorDimensions "default"
}
app3 {
applicationId 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
buildConfigField "String", "URL_BASE", "https://XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
versionCode 16
flavorDimensions "default"
signingConfig signingConfigs.Signing_Release
}
app4 {
applicationId 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
buildConfigField "String", "URL_BASE", "https://XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
versionCode 1
minSdkVersion 1
flavorDimensions "default"
signingConfig signingConfigs.Signing_Release
}
app5 {
applicationId 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
buildConfigField "String", "URL_BASE", "https://XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
versionCode 1
minSdkVersion 1
flavorDimensions "default"
signingConfig signingConfigs.Signing_Release
}
}
buildTypes {
debug {
buildConfigField "Boolean", "ANALYTICS_ENABLE", "false"
}
release {
buildConfigField "Boolean", "ANALYTICS_ENABLE", "true"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
ext {
playServicesVersion = '11.8.0'
retrofitVersion = '2.1.0'
mlVisionVersion = '18.0.2'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.crashlytics.sdk.android:crashlytics:2.9.9#aar') {
transitive = true;
}
implementation project(':camara')
implementation 'androidx.multidex:multidex:2.0.1'
implementation('com.afollestad:bridge:5.1.2') {
exclude group: 'org.json', module: 'json'
}
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.jakewharton:butterknife:10.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.instacart.truetime-android:library:3.3'
implementation 'com.google.android.gms:play-services-vision:17.0.2'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.firebase:firebase-messaging:17.5.0'
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.evernote:android-job:1.2.5'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.mcxiaoke.viewpagerindicator:library:2.4.1#aar'
implementation 'com.github.HotBitmapGG:RingProgressBar:V1.2.2'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.uncopt:android.justified:1.0'
implementation 'com.valdesekamdem.library:md-toast:0.9.0'
implementation 'io.realm:android-adapters:2.1.0'
implementation 'com.github.gcacace:signature-pad:1.2.1'
implementation 'me.relex:circleindicator:1.2.2#aar'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.grappes:Infinix-Indicator:1.0.2'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.savvi.datepicker:rangepicker:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.uphyca:stetho_realm:2.3.0'
implementation 'com.github.takusemba:spotlight:1.6.1'
// implementation "com.google.firebase:firebase-ml-vision:$mlVisionVersion"
implementation 'de.hdodenhof:circleimageview:3.0.0'
implementation 'com.robertlevonyan.view:MaterialChipView:1.2.5'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.2'
// TESTING
testImplementation 'junit:junit:4.12'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
apply plugin: 'realm-android'
apply plugin: 'com.google.gms.google-services'
Project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
//jcenter()
google()
jcenter({url "http://jcenter.bintray.com/"})
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "io.realm:realm-gradle-plugin:5.2.0"
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
//jcenter()
jcenter({url "http://jcenter.bintray.com/"})
mavenCentral()
maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/dgunjit14/Infinix-Indicator" }
google()
}
// Workaround for https://issuetracker.google.com/117900475
// Remove when upgrading to AGP 3.4 or higher.
configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
config.resolutionStrategy.eachDependency { details ->
details.useVersion("3.5.0-alpha03-5252756")
}
}
}
project.ext {
keyAlias = 'xxxxxxxx'
keyPassword = 'xxxxxxxx'
storeFile = 'xxxxxx.jks'
storePassword = 'xxxxxxxxxxx'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This library is no longer available. You can download JAR here: https://mvnrepository.com/artifact/com.afollestad/bridge/5.1.2
You should migrate to another solution as soon as possible.

Program type already present: android.support.compat.R$attr

My project has two modules i.e. app and moduleX.
app project is mostly built on Java and moduleX is completly in Kotlin.
While creating "debug" build, it's running fine but when I try to create release build i.e. devRelease, it give following error-
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDevRelease'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.compat.R$attr
Here is the app level build.gradle-
apply plugin: 'com.android.application'
apply plugin: 'com.facebook.testing.screenshot'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.appname"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner rootProject.ext.testInstrumentationRunner
}
flavorDimensions "environment"
productFlavors {
dev {
dimension "environment"
versionNameSuffix "-dev"
applicationIdSuffix ".dev"
}
qa {
dimension "environment"
versionNameSuffix "-test"
applicationIdSuffix ".test"
}
staging {
dimension "environment"
versionNameSuffix "-staging"
applicationIdSuffix ".staging"
}
prod {
dimension "environment"
}
}
signingConfigs {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
release {
storeFile file("keystore/appname_keystore.jks")
storePassword properties.getProperty('storePassword')
keyAlias properties.getProperty('keyAlias')
keyPassword properties.getProperty('keyPassword')
}
}
buildTypes {
debug {
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
shrinkResources false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
bundle {
language {
enableSplit = false
}
}
configurations.all {
resolutionStrategy {
// force certain versions of dependencies (including transitive)
force 'com.squareup.okhttp3:okhttp:' + okHttpLibVersion
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//Unit testing
testImplementation rootProject.ext.junit
androidTestImplementation rootProject.ext.androidTestRunner
androidTestImplementation rootProject.ext.espresso
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.facebookScreenshotTestCommon
implementation rootProject.ext.facebookScreenshotTestLitho
androidTestImplementation rootProject.ext.supportTestRules
//Support Library & UI
implementation rootProject.ext.constraintLayout
implementation rootProject.ext.supportCompatV7
implementation rootProject.ext.supportDesign
implementation rootProject.ext.supportCardView
implementation rootProject.ext.supportCustomTabs
implementation rootProject.ext.glide
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// Dagger dependency for DI
implementation 'com.google.dagger:dagger:2.16'
annotationProcessor "com.google.dagger:dagger-compiler:2.16"
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation 'javax.inject:javax.inject:1'
// RxJava lib
implementation rootProject.ext.rxAndroid
implementation rootProject.ext.rxJava
implementation rootProject.ext.rxJavaRetrofitAdapter
//Retrofit
implementation(rootProject.ext.retrofit) {
exclude module: 'okhttp'
}
implementation rootProject.ext.okHttp
implementation rootProject.ext.okHttpLoggingInterceptor
implementation rootProject.ext.retrofitGsonConverter
implementation rootProject.ext.retrofitScalarsConverter
//Memory leaks
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
//Others
implementation rootProject.ext.parceler
annotationProcessor rootProject.ext.parcelerAnnotationProcessor
implementation rootProject.ext.lombok
annotationProcessor rootProject.ext.lombokAnnotationProcessor
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
// Fingerprint Auth
implementation 'com.multidots:fingerprint-auth:1.0.1'
//Module Projects
api project(':energyswitchcui')
}
screenshots {
multipleDevices true
}
and here is the build.gradle file of moduleX-
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
// need separate runner for facebook screenshot test in module
testInstrumentationRunner 'com.appname.SnapshotTestRunner'
}
flavorDimensions "environment"
productFlavors {
dev {
dimension "environment"
}
qa {
dimension "environment"
}
staging {
dimension "environment"
}
prod {
dimension "environment"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Unit testing
testImplementation rootProject.ext.junit
androidTestImplementation rootProject.ext.androidTestRunner
androidTestImplementation rootProject.ext.espresso
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.facebookScreenshotTestCommon
implementation rootProject.ext.facebookScreenshotTestLitho
androidTestImplementation rootProject.ext.supportTestRules
//Support Library & UI
implementation rootProject.ext.constraintLayout
implementation rootProject.ext.supportCompatV7
implementation rootProject.ext.supportDesign
implementation rootProject.ext.supportCardView
implementation rootProject.ext.supportCustomTabs
implementation rootProject.ext.glide
implementation 'com.intuit.sdp:sdp-android:1.0.6'
// RxJava lib
implementation rootProject.ext.rxAndroid
implementation rootProject.ext.rxJava
implementation rootProject.ext.rxJavaRetrofitAdapter
//Retrofit
implementation(rootProject.ext.retrofit) {
exclude module: 'okhttp'
}
implementation rootProject.ext.okHttp
implementation rootProject.ext.okHttpLoggingInterceptor
implementation rootProject.ext.retrofitGsonConverter
implementation rootProject.ext.retrofitScalarsConverter
//Others
implementation rootProject.ext.parceler
kapt rootProject.ext.parcelerAnnotationProcessor
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
}
repositories {
mavenCentral()
}
// need for facebook screenshot test in module
apply plugin: 'com.facebook.testing.screenshot'
screenshots {
multipleDevices true
}
This is the project level build.gradle file-
apply from: 'dependencies.gradle'
buildscript {
ext.kotlinVersion = '1.3.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.facebook.testing.screenshot:plugin:0.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is dependencies.gradle-
ext {
//Android
minSdkVersion = 24
targetSdkVersion = 28
compileSdkVersion = targetSdkVersion
testInstrumentationRunner = "com.appname.runner.SnapshotTestRunner"
androidSupportLibVersion = "28.0.0"
okHttpLibVersion = "3.14.0"
//Unit testing
junit = "junit:junit:4.12"
androidTestRunner = "com.android.support.test:runner:1.0.2"
espresso = "com.android.support.test.espresso:espresso-core:3.0.2"
mockito = "org.mockito:mockito-all:1.10.19"
facebookScreenshotTestCommon = "com.facebook.testing.screenshot:layout-hierarchy-common:0.8.0"
facebookScreenshotTestLitho = "com.facebook.testing.screenshot:layout-hierarchy-litho:0.8.0"
supportTestRules = "com.android.support.test:rules:1.0.2"
//Support Library & UI
constraintLayout = "com.android.support.constraint:constraint-layout:1.1.3"
supportCompatV7 = "com.android.support:appcompat-v7:$androidSupportLibVersion"
supportDesign = "com.android.support:design:$androidSupportLibVersion"
supportCardView = "com.android.support:cardview-v7:$androidSupportLibVersion"
supportCustomTabs = "com.android.support:customtabs:$androidSupportLibVersion"
glide = "com.github.bumptech.glide:glide:3.7.0"
// RxJava lib
rxAndroid = "io.reactivex.rxjava2:rxandroid:2.0.1"
rxJava = "io.reactivex.rxjava2:rxjava:2.1.8"
rxJavaRetrofitAdapter = "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0"
//Retrofit
retrofit = "com.squareup.retrofit2:retrofit:2.4.0"
okHttp = "com.squareup.okhttp3:okhttp:$okHttpLibVersion"
okHttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:$okHttpLibVersion"
retrofitGsonConverter = "com.squareup.retrofit2:converter-gson:2.3.0"
retrofitScalarsConverter = "com.squareup.retrofit2:converter-scalars:2.3.0"
//Others
parceler = "org.parceler:parceler-api:1.1.6"
parcelerAnnotationProcessor = "org.parceler:parceler:1.1.6"
lombok = "org.projectlombok:lombok:1.16.16"
lombokAnnotationProcessor = "org.projectlombok:lombok:1.16.16"
}
I have already tried many answers i.e.
Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior
but nothing is working here.
Hi i have come up with the solution and run successful below gradles with just little version changes:
Main Project Level Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.facebook.testing.screenshot:plugin:0.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
//Android
minSdkVersion = 24
targetSdkVersion = 28
compileSdkVersion = targetSdkVersion
testInstrumentationRunner = "com.appname.runner.SnapshotTestRunner"
androidSupportLibVersion = "28.0.0"
androidCompatVersion = "1.0.0-beta01"
androidCardViewVersion = "1.0.0"
constraintlayoutVersion = "1.1.3"
okHttpLibVersion = "3.14.0"
//Unit testing
junit = "junit:junit:4.12"
androidTestRunner = "androidx.test:runner:1.1.0-alpha4"
espresso = "androidx.test.espresso:espresso-core:3.1.0-alpha4"
supportTestRules = "com.android.support.test:rules:1.0.2"
//Support Library & UI
constraintLayout = "androidx.constraintlayout:constraintlayout:$constraintlayoutVersion"
supportCompatV7 = "androidx.appcompat:appcompat:$androidCompatVersion"
supportDesign = "com.android.support:design:$androidSupportLibVersion"
supportCardView = "androidx.cardview:cardview:$androidCardViewVersion"
supportCustomTabs = "com.android.support:customtabs:$androidSupportLibVersion"
glide = "com.github.bumptech.glide:glide:3.7.0"
mockito = "org.mockito:mockito-all:1.10.19"
facebookScreenshotTestCommon = "com.facebook.testing.screenshot:layout-hierarchy-common:0.8.0"
facebookScreenshotTestLitho = "com.facebook.testing.screenshot:layout-hierarchy-litho:0.8.0"
// RxJava lib
rxAndroid = "io.reactivex.rxjava2:rxandroid:2.0.1"
rxJava = "io.reactivex.rxjava2:rxjava:2.1.8"
rxJavaRetrofitAdapter = "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0"
//Retrofit
retrofit = "com.squareup.retrofit2:retrofit:2.4.0"
okHttp = "com.squareup.okhttp3:okhttp:$okHttpLibVersion"
okHttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:$okHttpLibVersion"
retrofitGsonConverter = "com.squareup.retrofit2:converter-gson:2.3.0"
retrofitScalarsConverter = "com.squareup.retrofit2:converter-scalars:2.3.0"
//Others
parceler = "org.parceler:parceler-api:1.1.9"
parcelerAnnotationProcessor = "org.parceler:parceler:1.1.9"
lombok = "org.projectlombok:lombok:1.16.16"
lombokAnnotationProcessor = "org.projectlombok:lombok:1.16.16"
}
App Level gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.gradletest"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation rootProject.ext.junit
androidTestImplementation rootProject.ext.androidTestRunner
androidTestImplementation rootProject.ext.espresso
androidTestImplementation rootProject.ext.supportTestRules
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.facebookScreenshotTestCommon
implementation rootProject.ext.facebookScreenshotTestLitho
implementation rootProject.ext.constraintLayout
implementation rootProject.ext.supportCompatV7
implementation rootProject.ext.supportDesign
implementation rootProject.ext.supportCardView
implementation rootProject.ext.supportCustomTabs
implementation rootProject.ext.glide
// RxJava lib
implementation rootProject.ext.rxAndroid
implementation rootProject.ext.rxJava
implementation rootProject.ext.rxJavaRetrofitAdapter
//Retrofit
implementation(rootProject.ext.retrofit) {
exclude module: 'okhttp'
}
implementation rootProject.ext.okHttp
implementation rootProject.ext.okHttpLoggingInterceptor
implementation rootProject.ext.retrofitGsonConverter
implementation rootProject.ext.retrofitScalarsConverter
implementation rootProject.ext.parceler
// annotationProcessor rootProject.ext.parcelerAnnotationProcessor
implementation rootProject.ext.lombok
annotationProcessor rootProject.ext.lombokAnnotationProcessor
//Memory leaks
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.multidots:fingerprint-auth:1.0.1'
implementation project(':energyswitchcui')
}
Module("energyswitchcui") gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Unit testing
testImplementation rootProject.ext.junit
androidTestImplementation rootProject.ext.androidTestRunner
androidTestImplementation rootProject.ext.espresso
testImplementation rootProject.ext.mockito
testImplementation rootProject.ext.facebookScreenshotTestCommon
implementation rootProject.ext.facebookScreenshotTestLitho
androidTestImplementation rootProject.ext.supportTestRules
//Support Library & UI
implementation rootProject.ext.constraintLayout
implementation rootProject.ext.supportCompatV7
implementation rootProject.ext.supportDesign
implementation rootProject.ext.supportCardView
implementation rootProject.ext.supportCustomTabs
implementation rootProject.ext.glide
implementation 'com.intuit.sdp:sdp-android:1.0.6'
// RxJava lib
implementation rootProject.ext.rxAndroid
implementation rootProject.ext.rxJava
implementation rootProject.ext.rxJavaRetrofitAdapter
//Retrofit
implementation(rootProject.ext.retrofit) {
exclude module: 'okhttp'
}
implementation rootProject.ext.okHttp
implementation rootProject.ext.okHttpLoggingInterceptor
implementation rootProject.ext.retrofitGsonConverter
implementation rootProject.ext.retrofitScalarsConverter
//Others
implementation rootProject.ext.parceler
// kapt rootProject.ext.parcelerAnnotationProcessor
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
repositories {
mavenCentral()
}
// need for facebook screenshot test in module
apply plugin: 'com.facebook.testing.screenshot'
screenshots {
multipleDevices true
}
Below are the errors that were encountered during gradle and what i have done to solve it:
1) Error: Invoke-customs are only supported starting with Android O (--min-api 26)
Solution: put below lines under android section of app level gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
2) Error: The given artifact contains a string literal with a package reference 'android.support.v4.widget' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.
Solution: Removed "annotationProcessor rootProject.ext.parcelerAnnotationProcessor" from app level gradle and updated this library in main level gradle under "ext" section from 1.1.6 to 1.1.9 'parcelerAnnotationProcessor = "org.parceler:parceler:1.1.9"'
but it does not worked
So i removed that library and successfully build gradle and also can run the project. Here is the dropbox link you can find project on :https://www.dropbox.com/s/ki8gpfdaxh0dzo3/GradleTest.zip?dl=0
3) Above solution will work only in debug mode but in release build we have to also remove this two libraries to build successfully in release build:
facebookScreenshotTestCommon = "com.facebook.testing.screenshot:layout-hierarchy-common:0.9.0"
facebookScreenshotTestLitho = "com.facebook.testing.screenshot:layout-hierarchy-litho:0.9.0"

Execution failed for task ':app: lintVitalRelease' due to `Could not find multidex-instrumentation.aar`

When I try to sync my app module inside android studio it prompts error:
ERROR: Failed to resolve: multidex-instrumentation Affected Modules:
app
When I try to run gradlew assemble
Execution failed for task ':app:lintVitalRelease'.
Could not resolve all artifacts for configuration ':app:debugAndroidTestRuntimeClasspath'.
Could not find multidex-instrumentation.aar (androidx.multidex:multidex-instrumentation:2.0.0).
Searched in the following locations:
https://dl.google.com/dl/android/maven2/androidx/multidex/multidex-instrumentation/2.0.0/multidex-instrumentation-2.0.0.aar
solutions listed in this question did not fix my issue.
And an strange thing is that nothing as multidex-instrumentation-2.0.0 does not exist and I don't know why my app looks for such dependency.
Multidex-instrumentation 2.0.0 exists in Maven Repository.
Here are my build.gradle and app.gradle:
app.gradle
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 {
google()
jcenter()
maven {
url "https://maven.google.com"
}
maven { url 'https://maven.fabric.io/public' }
}
android {
// flavorDimensions ("resrouce")
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions{
disable 'MissingTranslation'
// checkReleaseBuilds false
// abortOnError false
}
defaultConfig {
applicationId 'com.myapp.android'
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName '1.0'
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "enableCrashlytics", "true"
ext.enableCrashlytics = true
}
releaseNonObfuscated {
minifyEnabled false
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-rules-debug.pro'
buildConfigField "boolean", "enableCrashlytics", "true"
ext.enableCrashlytics = false
}
debug {
versionNameSuffix '-DEBUG'
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "enableCrashlytics", "true"
ext.enableCrashlytics = true
}
}
dexOptions {
javaMaxHeapSize "2g"
}
sourceSets {
main {
res.srcDirs = [
'src/main/res',
'src/main/res/layout',
'src/main/res/layouts/product',
'src/myapp_eve/res'
]
}
}
productFlavors {
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
}
ext {
//support_library_version = '28.0.0'
smooch_chat_librar_version = '5.16.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//implementation 'com.android.support:28.0.0'
// implementation 'com.android.support:support-fragment:28.0.0'
// implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
// implementation 'com.android.support:collections:28.0.0'
// implementation 'com.android.support:versionedparcelable:28.0.0'
// implementation 'com.android.support:collections:28.0.0'
// implementation 'de.greenrobot:eventbus:2.4.0'
// implementation 'org.roboguice:roboguice:3.0.1'
// compileOnly 'org.roboguice:roboblender:4.0.0'
// annotationProcessor 'org.roboguice:roboblender:4.0.0'
// implementation 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
// compile 'com.paypal.sdk:paypal-android-sdk:2.12.4'
// compile 'com.braintreepayments.api:braintree:2.3.9'
// compile 'com.braintreepayments.api:drop-in:2.3.8'
// implementation 'com.facebook.android:facebook-android-sdk:4.23.+'
//implementation 'org.roboguice:roboblender:4.0.0'
// implementation 'com.jakewharton:butterknife:10.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha04'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'androidx.core:core:1.1.0-alpha05'
implementation 'androidx.annotation:annotation:1.1.0-beta01'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.github.rey5137:material:1.2.5'
implementation 'com.pnikosis:materialish-progress:1.5'
// implementation 'com.daimajia.slider:library:1.1.5#aar'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.commonsware.cwac:merge:1.1.2'
implementation 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.marshalchen.ultimaterecyclerview:library:0.3.18'
implementation 'com.github.markomilos:paginate:0.5.1'
implementation 'com.google.android.gms:play-services-vision:17.0.2'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.malinskiy:superrecyclerview:1.1.1'
implementation 'com.daimajia.swipelayout:library:1.2.0#aar'
implementation 'com.flipboard:bottomsheet-core:1.5.0'
implementation 'com.flipboard:bottomsheet-commons:1.5.0'
implementation 'org.apmem.tools:layouts:1.10#aar'
implementation(name: 'persiandatepicker-release', ext: 'aar')
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.8#aar') {
transitive = true;
}
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'com.binjar.prefsdroid:prefs-droid:1.1.0'
implementation 'com.google.firebase:firebase-messaging:17.6.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'org.jetbrains:annotations-java5:15.0'
implementation 'com.google.inject:guice:4.2.2'
implementation "io.smooch:core:${smooch_chat_librar_version}"
implementation "io.smooch:ui:${smooch_chat_librar_version}"
}
apply plugin: 'com.google.gms.google-services'
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://jitpack.io' }
}
dependencies {
//vahhab change to 3.2.0
classpath 'com.android.tools.build:gradle:3.3.1'
//classpath 'com.android.tools.build:gradle:3.2.1'
//classpath 'com.google.gms:google-services:2.0.0-alpha3'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.27.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://jitpack.io' }
flatDir { dirs 'libs' }
}
}
You should enable jetifier in the gradle.properties file.
android.enableJetifier=true
delete .gradle and .idea folders then rebuild the project.

Firebase is not working after apk is signed

I have used FCM to implement push notifications in my application. Now what issue I am facing is that when I run the build from my laptop the fcm runs perfectly and I get notifications. When I create a signed apk and upload on internal test channel in playstore it does not work although I can see the fcm token being updated at the backend where we have saved the token.
I saw in few questions where they as to add SHA-1 key in firebase console but I have already added that while adding the app in firebase. I also checked the app signing key in "Release Management - > App Signing" section in google play console, where it is showing the same SHA-1 key that I added while creating a project.
Now when i try to add the SHA-1 key in the console it is giving me issue of "Your operation was forbidden.". Help me out to how to make this work.
This is my gradle code :
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
maven { url "https://clojars.org/repo/" }
jcenter()
maven { url "https://jitpack.io" }
}
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.xx.xx"
minSdkVersion 16
targetSdkVersion 27
versionCode 291
versionName "2.8.6.9.10"
generatedDensities = []
vectorDrawables.useSupportLibrary = true
manifestPlaceholders = [manifestApplicationId : "${applicationId}",
onesignal_app_id : "xx",
onesignal_google_project_number: "xx"]
multiDexEnabled true
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', 'src/main/java-gen', 'src/main/Kotlin']
res.srcDirs = ['src/main/res']
}
beta {
res.srcDirs = ['src/beta/res']
}
main.java.srcDirs += 'src/main/kotlin'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
debuggable true
signingConfig signingConfigs.release
}
}
flavorDimensions("main", "beta")
productFlavors {
main {
minSdkVersion 16
dimension = "main"
}
beta {
minSdkVersion 21
dimension = "beta"
}
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
dexOptions {
jumboMode = true
}
lintOptions {
disable 'InvalidPackage'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
// debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
// releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
// testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
implementation "com.google.android.gms:play-services-location:$rootProject.playServicesVersion"
implementation "com.google.android.gms:play-services-maps:$rootProject.playServicesVersion"
implementation "com.google.android.gms:play-services-fitness:16.0.1"
implementation "com.google.android.gms:play-services-auth:16.0.1"
implementation "com.google.android.gms:play-services-plus:$rootProject.playServicesVersion"
implementation "com.google.android.gms:play-services-gcm:$rootProject.playServicesVersion"
implementation 'com.google.android.gms:play-services-analytics:16.0.4'
implementation "com.google.firebase:firebase-messaging:17.3.3"
implementation "com.google.firebase:firebase-core:16.0.4"
implementation "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:customtabs:$rootProject.supportLibraryVersion"
implementation "com.android.support:design:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
implementation "com.android.support:support-vector-drawable:$rootProject.supportLibraryVersion"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
implementation "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
implementation 'com.google.code.gson:gson:2.3.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true
}
implementation 'com.onesignal:OneSignal:3.6.1#aar'
implementation 'com.facebook.android:facebook-login:4.35.0'
implementation 'com.jakewharton:butterknife:8.0.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'
implementation 'de.greenrobot:greendao:2.1.0'
implementation 'org.greenrobot:eventbus:3.0.0'
//CirclePageIndicator
implementation 'com.viewpagerindicator:library:2.4.1#aar'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.clevertap.android:clevertap-android-sdk:3.1.2'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
implementation('com.github.anshulagarwal06:Lumiere:v1') {
exclude group: 'com.google.firebase'
}
implementation 'com.android.support:multidex:1.0.3'
implementation 'io.smooch:core:5.13.1'
implementation 'io.smooch:ui:5.13.1'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation 'uk.co.samuelwall:material-tap-target-prompt:2.6.0'
implementation 'com.neenbedankt.gradle.plugins:android-apt:1.8'
implementation('com.amazonaws:aws-android-sdk-mobile-client:2.6.+#aar') { transitive = true }
implementation 'com.amazonaws:aws-android-sdk-s3:2.6.22'
implementation 'com.amazonaws:aws-android-sdk-cognito:2.6.22'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.5.1'
implementation 'nl.dionsegijn:konfetti:1.1.2'
implementation 'com.github.freshdesk:freshchat-android:1.5.3'
}
apply plugin: 'com.google.gms.google-services'

Categories

Resources