androidx.appcompat.app.AppCompatActivity doesn't implement LifecycleOwner - android

I know looks like some stupid error, but I cannot find it.
In my project I have access to LifecycleOwner from my Fragments but not from Activity.
Here is my build.gradle
implementation project(':domain')
implementation project(':data')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// Koin for Android
implementation "org.koin:koin-android:$koin_version"
implementation "org.koin:koin-androidx-viewmodel:$koin_version"
// Anko
implementation "org.jetbrains.anko:anko-commons:$anko_version"
implementation "org.jetbrains.anko:anko-sdk15-listeners:$anko_version"
//Architecture components
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
Here is the Activity code:
And this is the source code of AppCompatActivity

As per this issue, this is a known issue if you use core-ktx:1.1.0 and appcompat:1.0.2, mixing alpha versions with stable releases. Upgrade to appcompat:1.1.0-alpha03 to fix the issue:
implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'

It's your core library. Also general rule of thumb for production code, try to avoid using alpha. Update the following libraries and you should be fine.
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1'

Related

Microsoft Graph v3.0.0 cause duplicate class javax.activation ... when compiling

After upgrading Microsoft Graph dependency in my project from implementation 'com.microsoft.graph:microsoft-graph:2.10.0' to implementation 'com.microsoft.graph:microsoft-graph:3.0.0' the compilation fails with following error:
Duplicate class javax.activation.ActivationDataFlavor found in modules jetified-activation-1.1 (javax.activation:activation:1.1) and jetified-jakarta.activation-api-1.2.1 (jakarta.activation:jakarta.activation-api:1.2.1)
Duplicate class javax.activation.CommandInfo found in modules jetified-activation-1.1 (javax.activation:activation:1.1) and jetified-jakarta.activation-api-1.2.1 (jakarta.activation:jakarta.activation-api:1.2.1)
...
Duplicate class javax.activation.UnsupportedDataTypeException found in modules jetified-activation-1.1 (javax.activation:activation:1.1) and jetified-jakarta.activation-api-1.2.1 (jakarta.activation:jakarta.activation-api:1.2.1)
Have any of you seen this before, and how do I fix this behaviour ?
Anyone knows if the changes in v3.0.0 are so severe that they can`t coexist with this dependency scheme ?
dependencies {
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-perf-ktx'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.3'
implementation 'androidx.core:core-ktx:1.5.0-beta03'
implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
implementation 'androidx.camera:camera-camera2:1.1.0-alpha02'
implementation 'androidx.camera:camera-lifecycle:1.1.0-alpha02'
implementation 'androidx.camera:camera-view:1.0.0-alpha22'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0-beta01'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'androidx.fragment:fragment-ktx:1.3.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.room:room-runtime:2.3.0-beta03'
kapt 'androidx.room:room-compiler:2.3.0-beta03'
implementation 'androidx.room:room-testing:2.3.0-beta03'
implementation 'androidx.room:room-ktx:2.3.0-beta03'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.2.0-beta02'
implementation ('com.microsoft.identity.client:msal:2.0.8')
{exclude group: 'com.microsoft.device.display'}
implementation ('com.microsoft.graph:microsoft-graph:3.0.0')
implementation 'com.google.android.material:material:1.4.0-alpha01'
//Guava, to avoid conflict on ListenableFuture on jetified-guava-20.0 (com.google.guava:guava:20.0)
// and jetified-listenablefuture-1.0 (com.google.guava.listenablefuture:1.0)
// https://stackoverflow.com/questions/56639529/duplicate-class-com-google-common-util-concurrent-listenablefuture-found-in-modu
implementation 'com.google.guava:guava:30.1-jre'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.maps.android:android-maps-utils:2.2.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.2'
}
Actually this version change is breaking, and here is the migration guide:
https://www.github.com/microsoftgraph/msgraph-sdk-java/tree/dev/docs%2Fupgrade-to-v3.md
But you might also add some exclusions in your packaging option in build.gradle (:app) like:
packagingOptions{
exclude("META-INF/INDEX.LIST")
exclude("META-INF/AL2.0")
exclude("META-INF/LGPL2.1")
exclude("META-INF/LICENSE.md")
exclude("META-INF/NOTICE.md")
exclude("META-INF/io.netty.versions.properties")
}
You might need add some more...

Incompatible types: Activity cannot be converted to LifecycleOwner

these are my dependencies
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
implementation "androidx.appcompat:appcompat-resources:1.2.0-beta01"
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.google.firebase:firebase-core:17.3.0'
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation 'com.google.firebase:firebase-messaging:20.1.5'
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:19.0.0'
implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:19.0.0'
implementation 'com.google.firebase:firebase-ml-common:22.0.1'
implementation 'com.rmtheis:tess-two:9.1.0'
testImplementation 'junit:junit:4.13'''
i have updated the androidx.appcompat:appcompat to the newest version(1.2.0-beta01) but the problem still not yet solved. Can anyone help me? I can provide more information as i have no idea which part of the code cause this error.
Thanks in advance

GSON not deleted

Why in my APK there is GSON even though I have nothing to implement GSON in Gradle?
Result Analyze APK
My Gradle :
//main
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.anko:anko-commons:0.10.5"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
implementation "androidx.recyclerview:recyclerview:1.1.0"
implementation "androidx.paging:paging-runtime:2.1.1"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.multidex:multidex:2.0.1"
implementation "com.android.volley:volley:1.1.1"
//google
implementation "com.google.android.gms:play-services-location:17.0.0"
implementation "com.google.android.material:material:1.0.0"
implementation "com.google.firebase:firebase-auth:19.2.0"
implementation "com.google.firebase:firebase-firestore:21.3.1"
implementation "com.google.firebase:firebase-storage:19.1.0"
implementation "com.google.firebase:firebase-messaging:20.1.0"
implementation "com.firebaseui:firebase-ui-storage:3.3.0"
// third party dependencies
implementation "com.balysv:material-ripple:1.0.2"
implementation "com.facebook.shimmer:shimmer:0.5.0"
implementation "com.squareup.moshi:moshi-kotlin:1.9.2"
implementation "com.tbuonomo.andrui:viewpagerdotsindicator:4.1.2"
implementation "com.github.bumptech.glide:glide:$glide_version"
//noinspection GradleDependency
implementation "com.journeyapps:zxing-android-embedded:3.6.0"
//kapt
kapt "com.github.bumptech.glide:compiler:$glide_version"
kapt "androidx.room:room-compiler:$room_version"
kapt "androidx.annotation:annotation:1.1.0"
// test
testImplementation 'junit:junit:4.13'
androidTestImplementation "androidx.test:runner:1.2.0"
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
I want to reduce my apk size, so I deleted the libary that I didn't use.
One or more of your dependencies has GSON in self.
i think it might be Glide or someone else.
for redecuing apk size check this topic might be helpful: Reduce the APK size - Android Developers

Android can't call setAnchorView on material Snackbar

this Snackbar is from package com.google.android.material.snackbar. it extends BaseTransientBottomBar< Snackbar > but there is no snackbar.setAnchorView or snackbar.anchorView.
Am I missing anything?
build.gradle
// Android
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
Use:
implementation 'com.google.android.material:material:1.1.0'
The method setAnchorView was introduced with 1.1.0-alpha01.
"view" in "make" method's arguments is that.
Android Developer Guide

How can I use FirestorePagingAdapter and options in my project?

I am trying to begin with FirestorePagingAdapter and FirestorePagingOptions
and I read the documentation carefully like here
https://github.com/firebase/FirebaseUI-Android/tree/master/firestore
and applied it by step by step
1-
implementation 'android.arch.paging:runtime:1.x.x'
2- Query baseQuery = mItemsCollection.orderBy("value", Query.Direction.ASCENDING);
But when I am trying to add FirestorePagingOptionsit appears by the red line code that means it is not imported or implemented well and I am not using any android architecture models. After a lot of searches, I found nothing clear about it
So what is the right way to begin with FirestorePagingAdapter ? what I should implement to begin with?
this is my implementation
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-core:16.0.3'
//google sign inj
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.google.firebase:firebase-firestore:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation 'com.google.firebase:firebase-storage:15.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.firebaseui:firebase-ui-firestore:3.3.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
//FIREBASE UI LIBRARY
implementation 'android.arch.lifecycle:runtime:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'android.arch.paging:runtime:1.0.1'
implementation 'android.arch.core:runtime:1.1.1'
implementation 'android.arch.core:common:1.1.1'
implementation 'android.arch.lifecycle:common-java8:1.1.1'
May be it's too late to answer. I reached to this page as I faced exactly the same issue.
Adding implementation 'com.firebaseui:firebase-ui-firestore:4.3.2' to the gradle dependencies solved this issue.

Categories

Resources