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'
Related
Hi all am try to add AR Functionalities to my project but getting an build error
Duplicate class a.a.a found in modules jetified-core-1.15.0-runtime (com.google.ar:core:1.15.0) and jetified-installreferrer-2.2-runtime (com.android.installreferrer:installreferrer:2.2)``
Go to the documentation to learn how to Fix dependency resolution errors.
after adding
`implementation ("com.google.ar.sceneform.ux:sceneform-ux:1.17.1")`
to the gradle.
below given are my gradle dependencies
final RETROFIT_VERSION = '2.9.0'
final BUTTER_KNIFE_VERSION = '10.2.3'
final DAGGER_VERSION = '2.42'
final OKHTTP_VERSION = '4.8.0'
final GLIDE_VERSION = '3.8.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
//AR Core SceneFrom
implementation "com.google.ar.sceneform.ux:sceneform-ux:1.17.1"
//material
implementation 'com.google.android.material:material:1.3.0'
//androidx
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.browser:browser:1.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
kapt 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.activity:activity-ktx:1.2.0"
implementation "androidx.fragment:fragment-ktx:1.3.0"
//dagger
implementation "com.google.dagger:dagger:$DAGGER_VERSION"
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
//retrofit
implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
implementation "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
implementation "com.squareup.retrofit2:adapter-rxjava2:$RETROFIT_VERSION"
//butter knife
implementation "com.jakewharton:butterknife:$BUTTER_KNIFE_VERSION"
kapt "com.jakewharton:butterknife-compiler:$BUTTER_KNIFE_VERSION"
//glide
implementation "com.github.bumptech.glide:glide:$GLIDE_VERSION"
//ok http
implementation "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"
implementation "com.squareup.okhttp3:logging-interceptor:$OKHTTP_VERSION"
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
//firebase
implementation platform('com.google.firebase:firebase-bom:26.6.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-config-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-core'
implementation('io.branch.sdk.android:library:5.1.4') {
exclude module: 'answers-shim'
}
//gson
implementation 'com.google.code.gson:gson:2.8.6'
//event bus
implementation 'org.greenrobot:eventbus:3.2.0'
//sdp
implementation 'com.intuit.sdp:sdp-android:1.0.6'
//circle image
implementation 'de.hdodenhof:circleimageview:3.1.0'
//aes
implementation 'com.scottyab:aescrypt:0.0.1'
//notify visitor
implementation 'com.notifyvisitors.notifyvisitors:notifyvisitors:5.3.3'
implementation 'com.android.installreferrer:installreferrer:2.2'
//razorpay
implementation 'com.razorpay:checkout:1.5.16'
implementation 'com.razorpay:razorpay-java:1.4.0'
//BillDesk
implementation project(path: ':BillDeskSDK_v2.1.3')
implementation project(path: ':slidetopick')
//ktx
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.fragment:fragment-ktx:1.3.3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
// lifecycle
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
//Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.5.2"
//test
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//biometric
implementation "androidx.biometric:biometric:1.1.0"
// reactive
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
//desugar
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
Tanks in advance if you are helping to fix this issue.
After updating some dependencies(not sure which one, but it includes navigation-ktx and fragment-ktx), "bundleOf" disappeared. Was it deleted? Autocomplete suggests me only "persistableBundleOf()", but it's not what I need.
P.S. I have "implementation 'androidx.core:core-ktx:1.3.2'" too.
UPD: My build.gradle:
implementation 'androidx.fragment:fragment-ktx:1.3.1'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
def navigation_version = "2.3.4"
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
I'm trying to integrate appodeal's sdk. and when trying to sync the project with Gradle, this error show's up:
Failed to resolve: legacy-support-core-ui-1.0.0
here are the dependencies:
dependencies {
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'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.exifinterface:exifinterface:1.2.0'
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
//volley
implementation 'com.android.volley:volley:1.1.0'
//mpchart
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
//Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
//Calligraphy
implementation 'io.github.inflationx:calligraphy3:3.1.1'
implementation 'io.github.inflationx:viewpump:2.0.3'
//appodeal
implementation 'com.appodeal.ads:sdk:2.6.5.0'
}
androidx.legacy:legacy-support-core-ui
This artifact and its classes are deprecated. Starting with Android 8,
background check restrictions make this class no longer useful.
You can remove
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
Then Clean-Rebuild-Restart IDE.
FYI
implementation 'com.appodeal.ads:sdk:2.6.5.+'
Make sure you added below in project-level build.gradle
allprojects {
repositories {
maven {
url "https://artifactory.appodeal.com/appodeal" // this is important
}
}
}
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
This is app module and tried removing implementation 'com.google.android.gms:play-services:12.0.1'
and changing the version to 17.0.0
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
testImplementation 'junit:junit:4.12'
implementation 'de.hdodenhof:circleimageview:2.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
}
apply plugin: 'com.google.gms.google-services'
i think the error was due to conflicting dependencies versions. i changed the firebase versions to:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
// implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-database:19.2.1'
implementation 'com.firebase:firebase-client-android:2.3.1'
implementation 'com.google.firebase:firebase-core:17.2.2'
testImplementation 'junit:junit:4.12'
implementation 'de.hdodenhof:circleimageview:2.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
}```