Android can't call setAnchorView on material Snackbar - android

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

Related

unresolved reference :viewModels

I am new to android kotlin and I am using viewModel in my OCR App."import androidx.fragment.app.viewModels" is not showing.I have added all the neccessary dependencies.What am doing wrong ?
Here are the dependencies.
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.android.material:material:1.2.1'
//lottie animation
implementation 'com.airbnb.android:lottie:3.4.1'
// Add CameraX dependencies
def camerax_version = "1.0.0-beta05"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
implementation "androidx.camera:camera-view:1.0.0-alpha12"
// Add ML Kit dependencies
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.0.0'
implementation 'com.google.mlkit:language-id:16.0.0'
implementation 'com.google.mlkit:translate:16.0.0'
}
And these is the import error.
Add this dependency to use by viewModels() in a Fragment:
implementation 'androidx.fragment:fragment-ktx:1.2.5'

while adding dependencies error came out in android studio

I'm making my own application by android studio, navigation drawer with Kotlin.
What I want to do in this step is changing to the new layout after tapping the sidebar's value.
For that, I need to add dependencies in my Gradle script.
I searched every website that I already knew. But I couldn't find out what is wrong with this.
As I know, dependencies should be located in build.gradle(:app).
// If my information is wrong, let me know what is the correct!
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
This is my project's dependencies line.
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.google.androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.androidx.recyclerview:recyclerview-selection:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
And This is what I changed to another code.
Please let me know what is the problem.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"
write top of the Gradle file before android {} tag
// default lib
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0'
implementation 'com.google.android.material:material:1.2.0'
// for kotlin
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
implementation 'androidx.fragment:fragment-ktx:1.2.5'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4'
I think this is enough for you to work with kotlin and jetpack components

Android: Cannot use TabLayout in my design even after migration to Android X

I'm sorry if I'm missing something obvious here, but I migrated my project to android X and still cannot use TabLayout in my layout files.
My dependencies in build.grade (app level):
dependencies {
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.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.airbnb.android:lottie:3.3.1'
implementation 'com.lorentzos.swipecards:library:1.0.9'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
I also tried to add:
implementation 'com.android.support:design:27.1.0'
And then Android studio marks it as error and tells me to upgrade to Android X (which I did already)
If it matters, my compile sdk version is 29
build tools: 29.0.2
Thanks in advance
use implementation 'com.google.android.material:material:1.0.0'. It includes Tablayout

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

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'

Got Error when adding googlemaps

Here is my dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:26.1.0'
implementation 'com.koushikdutta.ion:ion:2.2.1'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-core:11.6.2'
implementation 'com.google.firebase:firebase-messaging:11.6.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
}
apply plugin: 'com.google.gms.google-services'
when I added the last implementation which is com.google.android.gms:play-services-maps:15.0.1, I Got this error:
All firebase libraries must be either above or below 14.0.0
what's the problem?
You have two different Firebase. First, you're using the old version of firebase with:
implementation 'com.firebase:firebase-client-android:2.5.2'
Second, you're using the more recent Firebase version:
implementation 'com.google.firebase:firebase-core:11.6.2'
implementation 'com.google.firebase:firebase-messaging:11.6.2'
So, you need to migrate your old Firebase. You can do that by changing the old firebase dependency with:
implementation "com.google.firebase:firebase-database:15.0.0"
You must see the full step to migrate from your old Firebase on
Upgrade your Android app from Firebase.com
Also, you need to use the same version of Firebase and Google Play Service. In the end, your dependencies will be like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:26.1.0'
implementation 'com.koushikdutta.ion:ion:2.2.1'
implementation "com.google.firebase:firebase-database:15.0.0"
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
}
apply plugin: 'com.google.gms.google-services'

Categories

Resources