Android Failed looking up window with support version 27.0.0 - android

After the update of supportVersion to 27.0.0 ONLY on Android 5.0.2 the app crash with this stacktrace:
W/WindowManager: Failed looking up window
java.lang.IllegalArgumentException: Requested window android.view.ViewRootImpl$W#f004691 does not exist
at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8426)
at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:8417)
at com.android.server.wm.WindowManagerService.removeWindow(WindowManagerService.java:2558)
at com.android.server.wm.Session.remove(Session.java:186)
at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:2920)
at android.view.ViewRootImpl.doDie(ViewRootImpl.java:5390)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3223)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
at com.android.server.ServiceThread.run(ServiceThread.java:46)
Both on the device and on the emulator.
If I put 26.0.2 as supportVersion, the app still works normally as usual.
UPDATE
The problem persist with supportVersion 27.0.1
UPDATE 2
Project gradle
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'io.fabric.tools:gradle:1.24.2'
}
}
plugins {
id "com.diffplug.gradle.spotless" version "3.6.0"
}
allprojects {
repositories {
google()
jcenter()
jcenter { url = 'http://dl.bintray.com/swrve-inc/android' }
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://maven.localytics.com/public' }
maven { url 'http://dl.bintray.com/teads/TeadsSDK-android' }
maven { url 'http://maven.apptimize.com/artifactory/repo' }
maven { url 'https://comscore.bintray.com/Analytics' }
}
}
ext {
//APPLICATION
compileSdkVersion = 27
buildToolsVersion = '27.0.1'
minSdkVersion = 19
targetSdkVersion = 27
//LIBRARIES
timberVersion = '4.6.0'
guavaVersion = '20.0'
multidexVersion = '1.0.2'
supportVersion = '27.0.1'
constraintVersion = '1.0.2'
playServiceVersion = '11.4.0'
commonLangVersion = '3.5'
jacksonVersion = '2.4.2'
appsFlyerVersion = '4.7.1'
facebookAudienceVersion = '4.26.1'
facebookSkdVersion = '4.26.0'
facebookAdapterVersion = '4.26.1.0'
flurryVersion = '6.9.2'
googleTrackingVersion = '2.2.4'
crashliticsVersion = '2.6.8'
swrveVersion = '4.10.1'
swrveLocationVersion = '1.3'
pubnativeVersion = '2.0.5'
localyticsVersion = '4.3.1'
teadsVersion = '2.4.13'
oguryPresageVersion = '2.1.21'
evernoteAndroidJobVersion = '1.1.11'
apptimizeVersion = '2.13.5'
comScoreVersion = '5.5.1'
bottomBarVersion = '2.3.1'
rxJavaVersion = '2.1.6'
rxAndroidVersion = '2.0.1'
//TEST LIBRARIES
testsVersion = '1.0.1'
espressoVersion = '3.0.1'
junitVersion = '4.12'
mockitoVersion = '1.10.19'
powermockVersion = '1.6.6'
robolectricVersion = '3.5'
assertjVersion = '1.2.0'
//PUBNATIVE ADAPTERS
pnFlurryVersion = '6.9.2'
pnAdmobVersion = '9.6.1'
}
App gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
kotlin {
target "**/*.kt"
ktlint()
}
}
def versionMajor = 8
def versionMinor = 8
def versionPatch = 8
def versionBuild = 8
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
flavorDimensions "std"
defaultConfig {
dimension "std"
applicationId "xxx.yyy.zzz"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode versionMajor * 1000 + versionMinor * 100 + versionPatch * 10 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
//APP VERSION NAME
buildConfigField "String", "VERSION_NAME_PREFIX", "\"zzzz\""
//MARKET CONFIG
buildConfigField "String", "MARKET_NAME", "\"GooglePlay\""
buildConfigField "String", "MARKET_ENDPOINT", "\"market://details?id=\""
buildConfigField "String", "MARKET_BACKOFF_ENDPOINT", "\"https://play.google.com/store/apps/details?id=\""
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
....
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
buildTypes {
debug {
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
}
release {
minifyEnabled true
proguardFiles 'acb.txt'
zipAlignEnabled true
}
}
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds true
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
fatal 'StopShip'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
//CORE LIB
implementation "com.jakewharton.timber:timber:${rootProject.ext.timberVersion}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
implementation "com.google.guava:guava:${rootProject.ext.guavaVersion}"
implementation "com.android.support:multidex:${rootProject.ext.multidexVersion}"
implementation "com.android.support:multidex-instrumentation:${rootProject.ext.multidexVersion}"
implementation "com.android.support:design:${rootProject.ext.supportVersion}"
implementation "com.android.support:cardview-v7:${rootProject.ext.supportVersion}"
implementation "com.android.support.constraint:constraint-layout:${rootProject.ext.constraintVersion}"
implementation "com.google.android.gms:play-services-identity:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-base:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-analytics:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-gcm:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-location:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-maps:${rootProject.ext.playServiceVersion}"
implementation "com.google.android.gms:play-services-ads:${rootProject.ext.playServiceVersion}"
implementation "org.apache.commons:commons-lang3:${rootProject.ext.commonLangVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:${rootProject.ext.jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-core:${rootProject.ext.jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${rootProject.ext.jacksonVersion}"
implementation "io.reactivex.rxjava2:rxjava:${rootProject.ext.rxJavaVersion}"
implementation "io.reactivex.rxjava2:rxandroid:${rootProject.ext.rxAndroidVersion}"
//SDK
implementation "com.appsflyer:af-android-sdk:${rootProject.ext.appsFlyerVersion}#aar"
implementation "com.facebook.android:facebook-android-sdk:${rootProject.ext.facebookSkdVersion}"
implementation "com.facebook.android:audience-network-sdk:${rootProject.ext.facebookAudienceVersion}"
implementation "com.flurry.android:analytics:${rootProject.ext.flurryVersion}"
implementation "com.flurry.android:ads:${rootProject.ext.flurryVersion}"
implementation files("libs/GoogleConversionTrackingSdk-${rootProject.ext.googleTrackingVersion}.jar")
implementation("com.crashlytics.sdk.android:crashlytics:${rootProject.ext.crashliticsVersion}#aar") {
transitive = true
}
//TEADS VIDEO
implementation("tv.teads.sdk:androidsdk:${rootProject.ext.teadsVersion}:fullRelease#aar") {
transitive = true
}
//OGURY - PRESAGE
implementation files("libs/presage-lib-${rootProject.ext.oguryPresageVersion}-obfuscated.jar")
//PUBNATIVE
implementation "net.pubnative:sdk:${rootProject.ext.pubnativeVersion}"
//PUBNATIVE - ADAPTERS
implementation "net.pubnative:sdk.adapter.admob:${rootProject.ext.pnAdmobVersion}"
implementation "net.pubnative:sdk.adapter.flurry:${rootProject.ext.pnFlurryVersion}"
//ADMOB - ADAPTERS
implementation "com.google.ads.mediation:facebook:${rootProject.ext.facebookAdapterVersion}"
//SWRVE PLOT
implementation "com.swrve.sdk.android:swrve-google:${rootProject.ext.swrveVersion}"
implementation(name: "swrve-location-${rootProject.ext.swrveLocationVersion}", ext: "aar")
//LOCALYTICS
implementation "com.localytics.android:library:${rootProject.ext.localyticsVersion}"
//JOB
implementation "com.evernote:android-job:${rootProject.ext.evernoteAndroidJobVersion}"
//APPTIMIZE
implementation "com.apptimize:apptimize-android:${rootProject.ext.apptimizeVersion}"
//COMSCORE
implementation "com.comscore:android-analytics:${rootProject.ext.comScoreVersion}"
//BOTTOM BAR
implementation "com.roughike:bottom-bar:${rootProject.ext.bottomBarVersion}"
//TEST
androidTestImplementation "com.android.support:support-annotations:${rootProject.ext.supportVersion}"
androidTestImplementation "com.android.support.test:runner:${rootProject.ext.testsVersion}"
androidTestImplementation "com.android.support.test:rules:${rootProject.ext.testsVersion}"
androidTestImplementation "com.android.support.test.espresso:espresso-core:${rootProject.ext.espressoVersion}"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:${rootProject.ext.espressoVersion}"
androidTestImplementation("com.android.support.test.espresso:espresso-contrib:${rootProject.ext.espressoVersion}") {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude module: 'recyclerview-v7'
}
testImplementation "junit:junit:${rootProject.ext.junitVersion}"
testImplementation "org.mockito:mockito-core:${rootProject.ext.mockitoVersion}"
testImplementation "org.powermock:powermock-api-mockito:${rootProject.ext.powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4:${rootProject.ext.powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4-rule:${rootProject.ext.powermockVersion}"
testImplementation "org.powermock:powermock-classloading-xstream:${rootProject.ext.powermockVersion}"
testImplementation "org.robolectric:robolectric:${rootProject.ext.robolectricVersion}"
testImplementation "org.robolectric:shadows-multidex:${rootProject.ext.robolectricVersion}"
testImplementation "org.robolectric:shadows-httpclient:${rootProject.ext.robolectricVersion}"
testImplementation "com.android.support:support-annotations:${rootProject.ext.supportVersion}"
testImplementation "com.squareup.assertj:assertj-android:${rootProject.ext.assertjVersion}"
}
apply plugin: 'com.google.gms.google-services'

In my case it was due to the AppCompatActivity extend for the start activity, When it changed to Activity it is working fine!

You can try adding: maven { url "https://maven.google.com" }
Also set your support version to 27+
This has helped me in previous instance. Not tried it with 27.0.0 or 27.0.1
I know this is not the preferred approach but it can be used as a temporary fix. Wether you want to use it or ignore it, I leave it to you. But let me know if it works.

Related

A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction

Please help for the build error.
Kotlin version : 1.5.31
Gradle-zip: 7.2
Gradle version: 7.0.3
Execution failed for task ':app:mergeDebugJavaResource'.
A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path 'kotlin/internal/internal.kotlin_builtins' from inputs:
/Users/Umut/.gradle/caches/transforms-3/98f5d2ab243e47179d111ce52d349da0/transformed/jetified-kotlin-compiler-embeddable-1.5.31.jar
/Users/Umut/.gradle/caches/transforms-3/3af4d33202657704115aebc723152cf8/transformed/jetified-kotlin-stdlib-1.5.31.jar
Adding a packagingOptions block may help, please refer to
https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.PackagingOptions.html for more information
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
apply from: "$rootDir/ktlint.gradle"
android {
compileSdkVersion 31
buildToolsVersion "31.0.0"
defaultConfig {
applicationId "com.umut.example"
minSdkVersion 26
targetSdkVersion 31
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
useIR = true
}
bundle {
//Generate APKs for devices with different screen densities//
density {
enableSplit true
}
//Generate APKs for devices with different CPU architectures//
abi {
enableSplit true
}
//Create a split APK for each language//
language {
enableSplit false
}
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LGPL2.1'
exclude("META-INF/*.kotlin_module")
}
}
kapt {
correctErrorTypes = true
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
//test
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
testImplementation 'androidx.test.ext:junit-ktx:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
testImplementation "com.google.truth:truth:$truth_version"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation "org.robolectric:robolectric:$robolectric_version"
testImplementation "androidx.arch.core:core-testing:$archCoreTest_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlin_coroutines_version"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
//kotlin
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
//hilt
implementation "com.google.dagger:hilt-android:$dagger_hilt_version"
kapt("com.google.dagger:hilt-android-compiler:$dagger_hilt_version")
//retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$retrofit_coroutines_adapter_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
implementation "com.squareup.moshi:moshi-kotlin:$moshi_version"
kapt("com.squareup.moshi:moshi-kotlin-codegen:$moshi_version")
// okHttp3
implementation "com.squareup.okhttp3:okhttp:$okHttp_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okHttp_version"
implementation "com.squareup.okhttp3:okhttp-urlconnection:$okHttp_version"
//compose
implementation "androidx.activity:activity-compose:$compose_activity_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$compose_view_model_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.animation:animation:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation "androidx.constraintlayout:constraintlayout-compose:$constraintlayout_compose_version"
//3rd
implementation "androidx.multidex:multidex:$multidex_version"
implementation "com.airbnb.android:lottie-compose:$lottie_version"
implementation "com.pinterest:ktlint:$ktlint_version"
implementation "androidx.security:security-crypto:$security_crypto_version"
kapt "androidx.security:security-crypto-ktx:$security_crypto_version"
}
buildscript {
ext {
kotlin_version = '1.5.31'
security_crypto_version = "1.1.0-alpha03"
google_services_version = "4.3.10"
lifecycle_version = "2.4.0"
lifecycle_extensions_version = "2.2.0"
kotlin_coroutines_version = "1.5.2"
kotlin_serialization_version = "0.20.0"
compose_version = '1.0.5'
constraintlayout_compose_version = '1.0.0-rc02'
compose_activity_version = '1.4.0'
compose_view_model_version = '2.4.0'
okHttp_version = '4.9.2'
retrofit_version = '2.9.0'
moshi_version = '1.12.0'
dagger_hilt_version = '2.38.1'
retrofit_coroutines_adapter_version = '0.9.2'
lottie_version = '4.2.0'
truth_version = '1.1.3'
mockk_version = '1.12.1'
robolectric_version = '4.7.2'
archCoreTest_version = '2.1.0'
ktlint_version = "0.43.0"
multidex_version = "2.0.1"
}
repositories {
mavenCentral()
google()
maven { url "https://maven.google.com" }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.gms:google-services:$google_services_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$dagger_hilt_version"
}
}
allprojects {
repositories {
mavenCentral()
google()
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This happens because of the following dependency:
implementation "com.pinterest:ktlint:$ktlint_version"
ktlint must not be added as a dependency. See official documentation for installation instructions.

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"

No such property: betaDistributionApkFilePath while building with crashlytics

Today I updated to the latest version of crashlytics which was not updated from a very long time.
I am getting the below error while building the file.
Error:No such property: betaDistributionApkFilePath for class:
java.lang.String
I am not setting any betaDistributionApkFilePath property in my gradle file.
This happened after I updated it to the latest version by following the instructions given on the fabric's website. I tried down grading it to a bit older version, but no help. I also, tried to found out more about the error, but it seems that I am the first to face this.
my project level build.gradle
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
all*.exclude group: 'com.google.android.gms', module: 'play-services'
}
buildscript {
ext {
// root project
androidGradleVersion = "3.0.1"
googleServices = "3.2.0"
crashlytics = "1.25.1"
}
repositories {
jcenter()
mavenCentral()
google()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "com.android.tools.build:gradle:$androidGradleVersion"
classpath "com.google.gms:google-services:$googleServices"
classpath "io.fabric.tools:gradle:$crashlytics"
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my App level build.gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
ext {
// android
playService = "11.4.2"
supportLibrary = "27.0.2"
constrainLayout = "1.0.2"
// libraries
retofit = "1.9.0"
okHttp = "2.0.0"
eventBus = "1.3.8"
picasso = "2.5.2"
calligraphy = "2.3.0"
socketIo = "0.3.0"
facebook = "4.30.0"
circularReveal = "1.3.1"
imageCropper = "1.2.2"
expandableRecyclerView = "2.1.1"
crashlytics = "2.9.0"
selectableBackgroudImageView = "1.0.1"
multidex = "1.0.1"
}
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "myappid"
minSdkVersion 16
targetSdkVersion 21
versionCode 01
versionName "01"
multiDexEnabled true
}
buildTypes {
debug {
resValue "string", "app_name", "MyApp Dev"
applicationIdSuffix ".debug"
}
release {
resValue "string", "app_name", "MyApp"
zipAlignEnabled true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "6g"
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/res/anim-v21']
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
implementation files('libs/YouTubeAndroidPlayerApi.jar')
implementation "com.google.firebase:firebase-database:$playService"
implementation "com.google.firebase:firebase-auth:$playService"
implementation "com.google.firebase:firebase-core:$playService"
implementation "com.google.firebase:firebase-messaging:$playService"
implementation "com.google.android.gms:play-services-cast:$playService"
implementation "com.google.android.gms:play-services-gcm:$playService"
implementation "com.google.android.gms:play-services-analytics:$playService"
implementation "com.google.android.gms:play-services-maps:$playService"
implementation "com.google.android.gms:play-services-location:$playService"
implementation "com.google.android.gms:play-services-auth:$playService"
implementation "com.squareup.retrofit:retrofit:$retofit"
implementation "com.squareup.okhttp:okhttp-urlconnection:$okHttp"
implementation "com.squareup.okhttp:okhttp:$okHttp"
implementation "com.squareup:otto:$eventBus"
implementation "com.squareup.picasso:picasso:$picasso"
implementation "com.android.support:support-v4:$supportLibrary"
implementation "com.android.support:recyclerview-v7:$supportLibrary"
implementation "com.android.support:design:$supportLibrary"
implementation "com.android.support:appcompat-v7:$supportLibrary"
implementation "com.android.support:cardview-v7:$supportLibrary"
implementation "com.android.support:mediarouter-v7:$supportLibrary"
implementation "com.android.support.constraint:constraint-layout:$constrainLayout"
implementation "uk.co.chrisjenx:calligraphy:$calligraphy"
implementation "com.github.nkzawa:socket.io-client:$socketIo"
implementation "com.facebook.android:facebook-android-sdk:$facebook"
implementation "com.facebook.android:facebook-login:$facebook"
implementation "com.github.ozodrukh:CircularReveal:$circularReveal"
implementation "com.theartofdev.edmodo:android-image-cropper:$imageCropper"
implementation "com.bignerdranch.android:expandablerecyclerview:$expandableRecyclerView"
implementation("com.crashlytics.sdk.android:crashlytics:$crashlytics#aar") {
transitive = true
}
implementation "com.joooonho:selectableroundedimageview:$selectableBackgroudImageView"
implementation "com.android.support:multidex:$multidex"
}
apply plugin: 'com.google.gms.google-services'
Below lines in your app level build.gradle is causing the issue.
ext {
// android
playService = "11.4.2"
supportLibrary = "27.0.2"
constrainLayout = "1.0.2"
// libraries
retofit = "1.9.0"
okHttp = "2.0.0"
eventBus = "1.3.8"
picasso = "2.5.2"
calligraphy = "2.3.0"
socketIo = "0.3.0"
facebook = "4.30.0"
circularReveal = "1.3.1"
imageCropper = "1.2.2"
expandableRecyclerView = "2.1.1"
crashlytics = "2.9.0"
selectableBackgroudImageView = "1.0.1"
multidex = "1.0.1"
}
Declare it inside buildScript{} in project level build.gradle
buildscript {
ext {
crashlytics = '2.9.0'
}
}
And for accessing these variables inside app level build.gradle, use like this
compile("com.crashlytics.sdk.android:crashlytics:$rootProject.ext.crashlytics#aar") {
transitive = true
}
Hope this helps...

Cannot import AndroidJUnit4 and ActivityTestRule

I'm trying to make a class for instrumentation test. This class is in the androidTest folder app\src\androidTest\java\.... However, AndroidJUnit4 and ActivityTestRule cannot resolve. In the import statement, import android.support.test.runner.AndroidJUnit4 the word "runner" is in red. The test class is in Kotlin. I tried deleted it and created one in Java, but still cannot import AdnroidJUnit4. I read some similar questions but didn't find the solution to my case. Those two are the project and app build.gradle files:
Is there anything wrong with my gradle files?
app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.sample.me"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
archivesBaseName = "$applicationId-$versionName-$versionCode"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// For room compat
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":
"$projectDir/schemas".toString()]
}
}
}
sourceSets {
androidTest.assets.srcDirs +=
files("$projectDir/schemas".toString())
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
}
}
buildToolsVersion '27.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// Room
implementation "android.arch.persistence.room:runtime:$rootProject.ext.roomVersion"
kapt "android.arch.persistence.room:compiler:$rootProject.ext.roomVersion"
// Support libs
implementation "com.android.support:recyclerview-v7:$rootProject.ext.supportVersion"
implementation "com.android.support:design:$rootProject.ext.supportVersion"
implementation "com.android.support:cardview-v7:$rootProject.ext.supportVersion"
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportVersion"
implementation "com.android.support.test.espresso:espresso-idling-resource:$rootProject.ext.espressoVersion"
implementation 'joda-time:joda-time:2.9.9'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$rootProject.ext.kotlinVersion"
// Dependencies for local unit tests
testImplementation "junit:junit:$rootProject.ext.junitVersion"
testImplementation "org.hamcrest:hamcrest-all:$rootProject.ext.hamcrestVersion"
testImplementation "org.mockito:mockito-core:$rootProject.ext.mockitoVersion"
// Android Testing Support Library's runner and rules
androidTestImplementation "com.android.support.test:runner:$rootProject.ext.runnerVersion"
androidTestImplementation "com.android.support.test:rules:$rootProject.ext.runnerVersion"
// Dependencies for Android unit tests
androidTestImplementation "junit:junit:$rootProject.ext.junitVersion"
androidTestImplementation "org.mockito:mockito-android:$rootProject.ext.mockitoVersion"
//androidTestImplementation "com.android.support.test.espresso:espresso-core:$rootProject.ext.espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$rootProject.ext.espressoVersion"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:$rootProject.ext.espressoVersion"
// Resolve conflicts between main and test APK: not resolve
androidTestImplementation "com.android.support:support-annotations:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support:support-v4:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support:recyclerview-v7:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support:appcompat-v7:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support:design:$rootProject.ext.supportVersion"
androidTestImplementation "com.android.support.test.espresso.idling:idling-concurrent:$rootProject.ext.espressoVersion"
androidTestImplementation "android.arch.persistence.room:testing:$rootProject.ext.roomVersion"
}
repositories {
mavenCentral()
}
top build.gradle
ext {
// Sdk and tools
compileSdkVersion = 26
targetSdkVersion = 26
minSdkVersion = 19
buildToolsVersion = '27.0.1'
supportVersion = '27.0.2'
// App dependencies
espressoVersion = '3.0.1'
roomVersion = '1.1.0-alpha1'
junitVersion = '4.12'
mockitoVersion = '2.8.47'
hamcrestVersion = '1.3'
runnerVersion = '1.0.1'
rulesVersion = '1.0.1'
espressoVersion = '3.0.1'
}
buildscript {
ext.kotlinVersion = '1.2.21'
ext.gradlePluginVersion = '2.3.0'
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-beta1' // Use plain string for auto update
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
jcenter()
google()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
update Finally find out that this is because a blank space in project path. I removed the space and now can import the classes.
Try adding these in the dependancy these
androidTestCompile 'com.android.support.test:rules:1.0.2'
androidTestCompile 'com.android.support.test:runner:1.0.2'

Gradle 3.0 transformClassesWithStackFramesFixerForDebug duplicate entry

I've googled and searched in here the solution for this but haven't found it. I just updated my Android Studio to 3.0 and I'm trying to port my app to use feature modules in order to be able to make an Instant App, but when I try to run the app from Android Studio, I get the following error:
Error:Execution failed for task
':app:transformClassesWithStackFramesFixerForDebug'.
> com.android.build.api.transform.TransformException:
java.lang.RuntimeException: java.lang.RuntimeException:
java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.builder.utils.FileCache$FileCreatorException:
java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF
I tried to exclude such file using packagingOptions, but apparently is not working. Here are my build.gradle files:
Project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
compileSdkVersion = 26
supportLib = '26.1.0'
}
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
App module build.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 {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
maven { url "https://s3.amazonaws.com/avocarrot-android-builds/dist" }
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
maven { url "https://maven.google.com" }
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.myapp.mobile"
minSdkVersion 16
targetSdkVersion 26
versionCode 23004003
versionName "4.0.0.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
dexOptions {
javaMaxHeapSize "4g"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/MANIFEST.MF'
}
}
dependencies {
def mopub = '4.16.0#aar'
def avocarrot = '4.6.0'
def exoplayer = 'r2.2.0'
def mobfox = '3.2.3'
def pubnative = '2.0.4'
def facebook = '4.+'
def pubnativeFacebookAdapter = '2.0.2-4.22.1'
def taboola = '1.3.1'
def okhttp = '3.8.1'
def okio = '1.13.0'
def picasso = '2.5.2'
def firebase = '11.4.0'
def playServices = '11.4.0'
def supportLib = '26.1.0'
def gson = '2.8.1'
def circleimageview = '2.1.0'
def floatingactionbutton = '1.3.0'
def mpAndroidChart = 'v3.0.2'
def gridViewHeaderFooter = '1.0.12'
def multidex = '1.0.1'
def floatingsearchview = '2.0.3'
def cropper = '1.0.1#aar'
def adapterdelegates = '3.0.1'
def rxjava = '2.x.y'
def rxandroid = '2.0.1'
def rxjavaAdapter = '2.3.0'
def retrofit = '2.3.0'
def rxbinding = '2.0.0'
def diagonallayout = '1.0.6'
def fabSpeedDial = '1.0.6'
def butterknife = '8.7.0'
def sqlbrite = '2.0.0'
def leakcanary = '1.5.1'
def debugDB = '1.0.1'
def crashlytics = '2.6.8#aar'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/admarvel-android-sdk-core-adcolony.jar')
implementation files('libs/libAdapterSDKMoPub.jar')
implementation files('libs/AdMobMediationAdapter.jar')
implementation files('libs/lsmsdkadmobmediationadapter.jar')
implementation files('libs/MobFox-Android-AdMob-Adapter.jar')
implementation files('libs/gcm.jar')
implementation files('libs/achartengine-1.1.0.jar')
implementation files('libs/comscore.jar')
implementation files('libs/hmediaLib-1.3.0.jar')
implementation(name:'adux-1.0.0', ext:'aar')
implementation "com.avocarrot.sdk:mediation-sdk-nativead:$avocarrot"
implementation "com.google.android.exoplayer:exoplayer:$exoplayer"
implementation "com.facebook.android:audience-network-sdk:$facebook"
implementation "com.facebook.android:facebook-android-sdk:$facebook"
implementation "com.google.ads.mediation:facebook:$facebook"
implementation "com.github.mobfox:MobFox-Android-SDK-Core:$mobfox"
implementation "net.pubnative:sdk:$pubnative"
implementation "net.pubnative:sdk.adapter.facebook:$pubnativeFacebookAdapter"
implementation "com.squareup.okhttp3:okhttp:$okhttp"
implementation "com.squareup.okio:okio:$okio"
implementation "com.squareup.picasso:picasso:$picasso"
implementation "com.android.support:cardview-v7:$rootProject.supportLib"
implementation "com.android.support:support-v4:$rootProject.supportLib"
implementation "com.android.support:recyclerview-v7:$rootProject.supportLib"
implementation "com.android.support:design:$rootProject.supportLib"
implementation "com.android.support:customtabs:$rootProject.supportLib"
implementation "com.google.android.gms:play-services-analytics:$playServices"
implementation "com.google.android.gms:play-services-ads:$playServices"
implementation "com.google.android.gms:play-services-wearable:$playServices"
implementation "com.google.code.gson:gson:$gson"
implementation "de.hdodenhof:circleimageview:$circleimageview"
implementation "com.melnykov:floatingactionbutton:$floatingactionbutton"
implementation "com.github.PhilJay:MPAndroidChart:$mpAndroidChart"
implementation "in.srain.cube:grid-view-with-header-footer:$gridViewHeaderFooter"
implementation "com.android.support:multidex:$multidex"
implementation "com.github.arimorty:floatingsearchview:$floatingsearchview"
implementation "com.soundcloud.android:android-crop:$cropper"
implementation "com.hannesdorfmann:adapterdelegates3:$adapterdelegates"
implementation "io.reactivex.rxjava2:rxjava:$rxjava"
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid"
implementation "com.squareup.retrofit2:adapter-rxjava2:$rxjavaAdapter"
implementation "com.squareup.retrofit2:retrofit:$retrofit"
implementation "com.squareup.retrofit2:converter-gson:$retrofit"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp"
implementation "com.jakewharton.rxbinding2:rxbinding:$rxbinding"
implementation "com.jakewharton.rxbinding2:rxbinding-support-v4:$rxbinding"
implementation "com.github.florent37:diagonallayout:$diagonallayout"
implementation "io.github.yavski:fab-speed-dial:$fabSpeedDial"
implementation "com.google.firebase:firebase-messaging:$firebase"
implementation "com.jakewharton:butterknife:$butterknife"
implementation "com.squareup.sqlbrite2:sqlbrite:$sqlbrite"
annotationProcessor "com.jakewharton:butterknife-compiler:$butterknife"
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakcanary"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary"
testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary"
debugImplementation "com.amitshekhar.android:debug-db:$debugDB"
implementation("com.crashlytics.sdk.android:crashlytics:$crashlytics")
{
transitive = true
}
implementation(name: 'DebugSettings', ext: 'aar')
wearApp project(':wear')
implementation project(':myapp-base')
}
apply plugin: 'com.google.gms.google-services'
Base module build.gradle
apply plugin: 'com.android.feature'
repositories {
maven { url "https://maven.google.com" }
}
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion '26.0.2'
baseFeature true
defaultConfig {
minSdkVersion 16
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 {
api "com.android.support:appcompat-v7:$rootProject.supportLib"
implementation fileTree(dir: 'libs', include: ['*.jar'])
// 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'
application project(':app')
}
You're including the libs directory twice in your app's build.gradle
// Once
implementation fileTree(include: ['*.jar'], dir: 'libs')
// And once more, but more verbose
implementation files('libs/admarvel-android-sdk-core-adcolony.jar')
implementation files('libs/libAdapterSDKMoPub.jar')
implementation files('libs/AdMobMediationAdapter.jar')
implementation files('libs/lsmsdkadmobmediationadapter.jar')
implementation files('libs/MobFox-Android-AdMob-Adapter.jar')
implementation files('libs/gcm.jar')
implementation files('libs/achartengine-1.1.0.jar')
implementation files('libs/comscore.jar')
implementation files('libs/hmediaLib-1.3.0.jar')
This could be where your issue originates. Decide on one way to include these and let me know whether that works.

Categories

Resources